JavaScript 参考手册
Style borderImage 属性
指定作为 div 元素周围边框的图像
源代码:
点击运行 »
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>蜜蜂教程(mifengjc.com)</title> <style> #myDIV { border: 15px solid transparent; width: 250px; padding: 10px 20px; -webkit-border-image: url(border.png) 30 30 stretch; /* Safari 5 */ -o-border-image: url(border.png) 30 30 stretch; /* Opera 12 */ border-image: url(border.png) 30 30 stretch; } </style> </head> <body> <p>点击“尝试一下”按钮改变 DIV 元素的 border-image 属性:</p> <button onclick="myFunction()">尝试一下</button> <div id="myDIV"> <h1>您好</h1> </div> <script> function myFunction() { document.getElementById("myDIV").style.borderImage = "url(border.png) 30 30 round"; document.getElementById("myDIV").style.WebkitBorderImage = "url(border.png) 30 30 round"; /* 针对 Safari 5 的代码 */ document.getElementById("myDIV").style.OBorderImage = "url(border.png) 30 30 round"; /* 针对 Opera 12 的代码 */ } </script> </body> </html>
运行结果:
点击运行 »