Showing posts with label CSS3 Border Image. Show all posts
Showing posts with label CSS3 Border Image. Show all posts

Monday, 26 December 2011

CSS3 Border Image

CSS3 Border Image

 With the CSS3 border-image property you can use an image to create a border:
 The border-image property allows you to specify an image as a border!

Syntax:

 div
 {
 border-image:url(border.png) 30 30 round;
 -moz-border-image:url(border.png) 30 30 round; /* Firefox */
 -webkit-border-image:url(border.png) 30 30 round; /* Safari and Chrome */
 -o-border-image:url(border.png) 30 30 round; /* Opera */
 }

Example:


 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 <html>
 <head>
 <style type="text/css">
 div
 {
 border-width:15px;
 width:250px;
 padding:10px 20px;
 }
 #round
 {
 -moz-border-image:url(border.png) 30 30 round; /* Firefox */
 -webkit-border-image:url(border.png) 30 30 round; /* Safari and Chrome */
 -o-border-image:url(border.png) 30 30 round; /* Opera */
 border-image:url(border.png) 30 30 round;
 }
 #stretch
 {
 -moz-border-image:url(border.png) 30 30 stretch; /* Firefox */
 -webkit-border-image:url(border.png) 30 30 stretch; /* Safari and Chrome */
 -o-border-image:url(border.png) 30 30 stretch; /* Opera */
 border-image:url(border.png) 30 30 stretch;
 }
 </style>
 </head>
 <body>
 <p><b>Note:</b> Internet Explorer does not support the border-image property.</p>
 <p>The border-image property specifies an image to be used as a border.</p>
 <div id="round">Here, the image is tiled (repeated) to fill the area.</div>
 <br />
 <div id="stretch">Here, the image is stretched to fill the area.</div>
 <p>Here is the image used:</p>
 <img src="border.png" />
 </body>
 </html>

Result: