CSS3 border-image 属性 | CSS3教程:CSS3 边框

返回到:CSS3 边框 | CSS3教程

属性定义及使用说明

border-image属性是速记属性用于设置 border-image-source, border-image-slice, border-image-width, border-image-outset 和border-image-repeat 的值。

省略的值设置为它们的默认值。

提示: 使用border-image-*属性来构建美丽的可扩展按钮!

默认值:none 100% 1 0 stretch
继承:no
版本:CSS3
JavaScript 语法:object.style.borderImage=”url(border.png) 30 30 round”

语法

border-image: source slice width outset repeat|initial|inherit;
描述
border-image-source用于指定要用于绘制边框的图像的位置
border-image-slice图像边界向内偏移
border-image-width图像边界的宽度
border-image-outset用于指定在边框外部绘制 border-image-area 的量
border-image-repeat用于设置图像边界是否应重复(repeat)、拉伸(stretch)或铺满(round)。

浏览器支持

表格中的数字表示支持该属性的第一个浏览器版本号。

紧跟在 -webkit-, -ms- 或 -moz- 前的数字为支持该前缀属性的第一个浏览器版本号。

属性谷歌IE火狐苹果opera
border-image16.0
4.0 -webkit-
11.015.0
3.5 -moz-
6.0
3.1 -webkit-
15.0
11.0 -o-

实例

指定作为div元素周围边框的图像:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>Web176教程网(web176.com)</title>
<style> 
div
{
	border:15px solid transparent;
	width:250px;
	padding:10px 20px;
}

#round
{
	-webkit-border-image:url(/wp-content/uploads/2022/01/border.png) 30 30 round; /* Safari 5 and older */
	-o-border-image:url(/wp-content/uploads/2022/01/border.png) 30 30 round; /* Opera */
	border-image:url(/wp-content/uploads/2022/01/border.png) 30 30 round;
}

#stretch
{
	-webkit-border-image:url(/wp-content/uploads/2022/01/border.png) 30 30 stretch; /* Safari 5 and older */
	-o-border-image:url(/wp-content/uploads/2022/01/border.png) 30 30 stretch; /* Opera */
	border-image:url(/wp-content/uploads/2022/01/border.png) 30 30 stretch;
}
</style>
</head>
<body>

<p><b>注意: </b> Internet Explorer 不支持 border-image 属性。</p>
<p> border-image 属性用于设置图片的边框。</p>

<div id="round">这里,图像平铺(重复)来填充该区域。</div>
<br>
<div id="stretch">这里,图像被拉伸以填充该区域。</div>

<p>这是我们使用的图片素材:</p>
<img src="/wp-content/uploads/2022/01/border.png" />

</body>
</html>

作者:terry,如若转载,请注明出处:https://www.web176.com/css3border/5225.html

(0)
打赏 支付宝 支付宝 微信 微信
terryterry
上一篇 2022年1月18日 下午2:56
下一篇 2022年1月18日 下午3:05

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注