Computer >> Máy Tính >  >> Lập trình >> CSS

Đặt hình ảnh làm đường viền cho các phần tử bằng CSS

Thuộc tính CSS border-image được sử dụng để thêm đường viền hình ảnh vào một số phần tử. Bạn có thể thử chạy mã sau để đặt hình ảnh làm đường viền cho các phần tử:

Ví dụ

<html>
   <head>
      <style>
         #borderimg1 {
            border: 10px solid transparent;
            padding: 15px;
            border-image-source: url(/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(/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(/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>