Saturday, April 15, 2017

CSS3 Border Images

CSS3 Border Images

With the CSS3 border-image property, you can set an image to be used as the border around an element.


CSS3 border-image Property

The CSS3 border-image property allows you to specify an image to be used instead of the normal border around an element.
The property has three parts:
  1. The image to use as the border
  2. Where to slice the image
  3. Define whether the middle sections should be repeated or stretched
We will use the following image (called "border.png"):
Border
The border-image property takes the image and slices it into nine sections, like a tic-tac-toe board. It then places the corners at the corners, and the middle sections are repeated or stretched as you specify.
Note: For border-image to work, the element also needs the border property set!
Here, the middle sections of the image are repeated to create the border:
An image as a border!
Here is the code:

<!DOCTYPE html>
<html>
<head>
<style> 
#borderimg { 
    border: 10px solid transparent;
    padding: 15px;
    -webkit-border-image: url(border.png) 30 round; /* Safari 3.1-5 */
    -o-border-image: url(border.png) 30 round; /* Opera 11-12.1 */
    border-image: url(border.png) 30 round;
}
</style>
</head>
<body>

<p>The border-image property specifies an image to be used as the border around an element:</p>
<p id="borderimg">Here, the middle sections of the image are repeated to create the border.</p>

<p>Here is the original image:</p><img src="border.png">
<p><strong>Note:</strong> Internet Explorer 10, and earlier versions, do not support the border-image property.</p>

</body>
</html>



No comments:
Write comments

Recommended Posts × +