Categories
CSS Web development

CSS border-image-repeat Property

CSS border-image-repeat Property

The CSS border-image-repeat property defines whether the border-image should be repeated, rounded or stretched.

Demo:

Syntax:

border-image-repeat: stretch|repeat|round|space;

stretch (default) – the image is stretched to fill the area.

repeat – the image is repeated to fill the area.

round – the image is repeated to fill the area (if it does not fill the area with a whole number of tiles, the image is rescaled so it fits).

space – the image is repeated to fill the area (if it does not fill the area with a whole number of tiles, the extra space is distributed around the tiles).

Example:

<!DOCTYPE html>
<html>
<head>
<style> 
#borderimg-1 { 
  border: 15px solid transparent;
  padding: 15px;
  border-image-source: url(https://lenadesign.org/wp-content/uploads/2021/09/border-1.png);
  border-image-repeat: repeat;
  border-image-slice: 30;
}

#borderimg-2 { 
  border: 15px solid transparent;
  padding: 15px;
  border-image-source: url(https://lenadesign.org/wp-content/uploads/2021/09/border-1.png);
  border-image-repeat: round;
  border-image-slice: 30;
}

#borderimg-3 { 
  border: 15px solid transparent;
  padding: 15px;
  border-image-source: url(https://lenadesign.org/wp-content/uploads/2021/09/border-1.png);
  border-image-repeat: stretch;  
  border-image-slice: 30;
}
</style>
</head>
<body>

<h4>border-image-repeat: repeat;</h4>
<p id="borderimg-1">Here, the image tiles to fill the area. Tiles are divided if necessary.</p>

<h4>border-image-repeat: round;</h4>
<p id="borderimg-2">Here, the image tiles to fill the area. The image is rescaled if necessary, to avoid dividing tiles.</p>

<h4>border-image-repeat: stretch;</h4>
<p id="borderimg-3">Here, the image is stretched to fill the area.</p>

</body>
</html>

Output:

border-image-repeat: repeat;

Here, the image tiles to fill the area. Tiles are divided if necessary.

border-image-repeat: round;

Here, the image tiles to fill the area. The image is rescaled if necessary, to avoid dividing tiles.

border-image-repeat: stretch;

Here, the image is stretched to fill the area.


The original image:

CSS border-image Property

Enjoy coding!

Read also:

CSS Border Property

Advanced CSS Border-radius/ Drop Shape, Lemon Shape, Leaf Shape & Egg Shape