With the CSS border-image
property, you can set an image to be used as the border around an element.
La propiedad CSS border-image
le permite especificar una imagen que se utilizará en lugar del borde normal alrededor de un elemento.
La propiedad tiene tres partes:
La imagen a usar como borde.
Dónde cortar la imagen
Definir si las secciones intermedias deben repetirse o estirarse.
Usaremos la siguiente imagen (llamada "border.png"):
La propiedad border-image
toma la imagen y la divide en nueve secciones, como un tablero de tres en raya. Luego coloca las esquinas en las esquinas, y el Las secciones intermedias se repiten o estiran según lo especifique.
Nota: Para que imagen de borde
funcione, el elemento también necesita la ¡Propiedad frontera
establecida!
Aquí, las secciones centrales de la imagen se repiten para crear el borde:
An image as a border!
Aquí está el código:
#borderimg
{
border: 10px solid transparent;
padding: 15px;
border-image: url(border.png)
30 round;
}
Pruébelo usted mismo →
<!DOCTYPE html>
<html>
<head>
<style>
#borderimg {
border: 10px solid transparent;
padding: 15px;
border-image: url(border.png) 30 round;
}
</style>
</head>
<body>
<h1>The border-image Property</h1>
<p>Here, the middle sections of the image are repeated to create the border:</p>
<p id="borderimg">border-image: url(border.png) 30 round;</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>
Aquí, las secciones centrales de la imagen se estiran para crear el borde:
An image as a border!
Aquí está el código:
#borderimg
{
border: 10px solid transparent;
padding: 15px;
border-image: url(border.png)
30 stretch;
}
Pruébelo usted mismo →
<!DOCTYPE html>
<html>
<head>
<style>
#borderimg {
border: 10px solid transparent;
padding: 15px;
border-image: url(border.png) 30 stretch;
}
</style>
</head>
<body>
<h1>The border-image Property</h1>
<p>Here, the middle sections of the image are stretched to create the border:</p>
<p id="borderimg">border-image: url(border.png) 30 stretch;</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>
Consejo: La propiedad border-image
es en realidad una propiedad abreviada de las propiedades:
border-image-source
border-image-slice
border-image-width
border-image-outset
border-image-repeat
Diferentes valores de corte cambian completamente el aspecto del borde:
Ejemplo 1:
border-image: url(border.png) 50 round;
Ejemplo 2:
border-image: url(border.png) 20% round;
Ejemplo 3:
border-image: url(border.png) 30% round;
Aquí está el código:
#borderimg1 {
border: 10px solid transparent;
padding: 15px;
border-image: url(border.png)
50 round;
}
#borderimg2 {
border: 10px solid transparent;
padding: 15px;
border-image: url(border.png) 20% round;
}
#borderimg3 {
border: 10px solid transparent;
padding: 15px;
border-image: url(border.png)
30% round;
}
Pruébelo usted mismo →
<!DOCTYPE html>
<html>
<head>
<style>
#borderimg1 {
border: 10px solid transparent;
padding: 15px;
border-image: url(border.png) 50 round;
}
#borderimg2 {
border: 10px solid transparent;
padding: 15px;
border-image: url(border.png) 20% round;
}
#borderimg3 {
border: 10px solid transparent;
padding: 15px;
border-image: url(border.png) 30% round;
}
</style>
</head>
<body>
<h1>The border-image Property</h1>
<p id="borderimg1">border-image: url(border.png) 50 round;</p>
<p id="borderimg2">border-image: url(border.png) 20% round;</p>
<p id="borderimg3">border-image: url(border.png) 30% round;</p>
<p><strong>Note:</strong> Internet Explorer 10, and earlier versions, do not support the border-image property.</p>
</body>
</html>
Una propiedad abreviada para configurar todas las propiedades de border-image-*
Especifica la ruta a la imagen que se utilizará como borde.
Especifica cómo dividir la imagen del borde.
Especifica los anchos de la imagen del borde.
Especifica la cantidad en la que el área de la imagen del borde se extiende más allá del cuadro del borde.
Especifica si la imagen del borde debe repetirse, redondearse o estirarse.