简单教程
提交运行
代码编辑器:
<style> #myDIV{ border:1px solid black; width:300px; height:150px; padding:35px; background:url('/static/i/smiley.gif') no-repeat; } </style> <p>点击“尝试一下”按钮设置 DIV 元素的 background-origin 属性为 "content-box":</p> <button onclick="myFunction()">尝试一下</button> <div id="myDIV"> Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. </div> <script> function myFunction(){ document.getElementById("myDIV").style.backgroundOrigin = "content-box"; } </script>
运行结果: