Computer >> Computer tutorials >  >> Programming >> CSS

Set image as a border for elements with CSS


CSS border-image property is used to add image border to some elements. You can try to run the following code to set the image as a border for elements:

Example

<html>
   <head>
      <style>
         #borderimg1 {
            border: 10px solid transparent;
            padding: 15px;
            border-image-source: url(/https/www.wsxdn.com/css/images/border.png);
            border-image-repeat: round;
            border-image-slice: 30;
            border-image-width: 10px;
         }
         #borderimg2 {
            border: 10px solid transparent;
            padding: 15px;
            border-image-source: url(/https/www.wsxdn.com/css/images/border.png);
            border-image-repeat: round;
            border-image-slice: 30;
            border-image-width: 20px;
         }
         #borderimg3 {
            border: 10px solid transparent;
            padding: 15px;
            border-image-source: url(/https/www.wsxdn.com/css/images/border.png);
            border-image-repeat: round;
            border-image-slice: 30;
            border-image-width: 30px;
         }
      </style>
   </head>
   <body>
      <p id = "borderimg1">This is image border example.</p>
      <p id = "borderimg2">This is image border example.</p>
      <p id = "borderimg3">This is image border example.</p>
   </body>
</html>