运行结果尺寸: 300 x 150
x
 
<!DOCTYPE html>
<html>
<head>
<style> 
#myDIV {
  border: 15px solid transparent;
  padding: 15px;
  border-image:url(border.png) 30 stretch;
}
</style>
</head>
<body>
<h1>使用 JavaScript 更改边框图像</h1>
<p>单击“试一试”按钮更改 DIV 元素的 border-image 属性:</p>
<button onclick="myFunction()">试一试</button>
<br><br>
<div id="myDIV">
  <h1>Hello</h1>
</div>
<p><b>注意:</b> Internet Explorer 10 及更早版本不支持 border-image 属性。</p>
<script>
function myFunction() {
  document.getElementById("myDIV").style.borderImage = "url(border.png) 30 round";
}
</script>
</body>
</html>
×

报个问题: