简单教程
提交运行
代码编辑器:
<style> #myDIV{ width:300px; height:300px; padding:50px; background-color:coral; background-clip:border-box; color:white; border:5px dotted lightgrey; } </style> <p>点击“尝试一下”按钮设置 DIV 元素的 background-clip 属性为 "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. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. </div> <script> function myFunction(){ document.getElementById("myDIV").style.backgroundClip = "content-box"; } </script>
运行结果: