fmpq.com
源代码:
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Fmpq教程(fmpq.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>
运行结果