Style borderImageSource 属性
使用图像作为环绕 div 元素的边框:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>蜜蜂教程(mifengjc.com)</title>
<style>
div {
background-color: lightgrey;
border: 30px solid transparent;
border-image: url("/examples/border.png");
border-image-slice: 30;
border-image-width: 1 1 1 1;
border-image-outset: 0;
border-image-repeat: round;
}
</style>
</head>
<body>
<div id="main">
<p>
这是一个使用图像作为边框的 DIV 元素。
</p>
</div>
<p>下面是两个要使用的图像:</p>
<img src="/examples/border.png">
<img src="/examples/img_flwr.gif">
<p>点击“尝试一下”按钮改变 borderImageSource 属性的值。</p>
<button onclick="myFunction()">尝试一下</button>
<script>
function myFunction() {
document.getElementById("main").style.borderImageSource = "url(" / examples / img_flwr.gif ")";
}
</script>
<p><b>注意:</b>Internet Explorer 10、Opera 和 Safari 5 不支持 borderImageSource 属性。</p>
</body>
</html>
定义和用法
borderImageSource 属性设置或返回要使用的图像,而不是使用 border-style 属性给定的边框样式。
提示:如果值为 "none",或者如果图像不显示,则使用边框样式。
浏览器支持
Opera 不支持 borderImageSource 属性。
Internet Explorer 10 及其之前的版本不支持 borderImageSource 属性。
Safari 5 及其之前的版本不支持 borderImageSource 属性。
请参阅 borderImage 属性来替代它!
语法
返回 borderImageSource 属性:
object.style.borderImageSource
设置 borderImageSource 属性:
object.style.borderImageSource = "none|image|initial|inherit"
属性值
值 | 描述 |
---|---|
none | 不使用图像。 |
image | 要用于绘制边框的图像的路径。 |
initial | 设置该属性为它的默认值。请参阅 initial。 |
inherit | 从父元素继承该属性。请参阅 inherit。 |
技术细节
默认值: | none |
---|---|
返回值: | 字符串,表示元素的 border-image-source 属性。 |
CSS 版本 | CSS3 |
相关文章
CSS 参考手册:border-image-source 属性