[HTML] CSS3 border

Source: Internet
Author: User

CSS3 border

With CSS3, you can create rounded borders, add shaded frames, and act as a boundary image without using a design program, such as Photoshop.

In this chapter, you will learn about the following border properties:

    • Border-radius

    • Box-shadow

    • Border-image

Browser support

Internet Explorer + + supports Border-radius and Box-shadow.

Firefox, Chrome, and Safari support all the latest border properties.

Note: The prefix is-webkit-for safari support for shaded borders.

The prefix is-o-'s opera support border image.

CSS3 rounded Corners

Adding fillets to CSS2 is tricky. We have to use different images in every corner.

In CSS3, it is easy to create rounded corners.

In CSS3, the Border-radius property is used to create fillets:

This is a rounded border! To add a fillet element to the div:
Div {Border:2px solid; Border-radius:25px;}

Instance:

<!DOCTYPE HTML><HTML><Head><MetaCharSet= "Utf-8"> <title>W3cschool Tutorial (w3cschool.cn)</title> <style>Div{Border:2px solid #a1a1a1;padding:10px 40px;background:#dddddd;width:300px;Border-radius:40px;}</style></Head><Body><Div>Border-radius</Div></Body></HTML>
CSS3 Box Shadow

The Box-shadow attribute in CSS3 is used to add a shadow:

Div {Box-shadow: 10px 10px 5px #888888;}

Instance:

<!DOCTYPE HTML><HTML><Head><MetaCharSet= "Utf-8"> <title>W3cschool Tutorial (w3cschool.cn)</title> <style>Div{width:300px;Height:100px;Background-color:Yellow;Box-shadow:10px 10px 5px #888888;}</style></Head><Body><Div></Div></Body></HTML>
CSS3 Border Picture

With the CSS3 Border-image property, you can create a border with an image:

The Border-image property allows you to specify a picture as a border! The original image used to create the border above:

Use a picture to create a border in a div:

Create a border with a picture in a div

Div {border-image:url (border.png) round; -webkit-border-image:url (border.png)-round*/**- O-border-image:url (border.png)-round/**/}

Instance:

<!DOCTYPE HTML><HTML><Head><MetaCharSet= "Utf-8"> <title>W3cschool Tutorial (w3cschool.cn)</title> <style>Div{Border:15px Solid Transparent;width:250px;padding:10px 20px;}#round{-webkit-border-image:URL (border.png) round; /*Safari 5 and older*/-o-border-image:URL (border.png) round; /*Opera*/Border-image:URL (border.png) round;}#stretch{-webkit-border-image:url (border.png) stretch; /*Safari 5 and older*/-o-border-image:url (border.png) stretch; /*Opera*/Border-image:url (border.png) stretch;}</style></Head><Body><P><b>Attention:</b>Internet Explorer does not support the Border-image property.</P><P>The Border-image property is used to set the border of a picture.</P><DivID= "Round">Here, the image is tiled (repeated) to fill the area.</Div><BR><DivID= "Stretch">Here, the image is stretched to fill the area.</Div><P>This is the image material we use:</P><imgsrc= "/statics/images/border.png" /></Body></HTML>

[HTML] CSS3 border

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.