The CSS border-image property permits the specification of an image for the border of an element, replacing the default border.
This property consists of three components:
We’ll employ the provided image (named “border.png”) for this purpose.
The border-image property divides the image into nine sections akin to a tic-tac-toe board. Subsequently, it positions the corners at the element’s corners, while the middle sections are either repeated or stretched based on your specifications.
Note: To enable border-image functionality, the element must also have the border property defined.
In this case, the border is formed by repeating the middle sections of the image.
Below is the provided code:
Example
#borderimg { border: 10px solid transparent; padding: 15px; border-image: url(border.png) 30 round; } |
In this instance, the border is generated by stretching the middle sections of the image.
The following is the code snippet:
Example
#borderimg { border: 10px solid transparent; padding: 15px; border-image: url(border.png) 30 stretch; } |
Tip: The border-image property functions as a shorthand for the border-image-source, border-image-slice, border-image-width, border-image-outset, and border-image-repeat properties. |
Varying slice values drastically alter the appearance of the border.
Illustration 1:
Illustration 2:
Illustration 3:
Below is the provided code:
Example
#borderimg1 { |