JavaScript 参考手册
Style backgroundClip 属性
指定背景的绘制区域
源代码:
点击运行 »
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>蜜蜂教程(mifengjc.com)</title> <style> #myDIV { width: 300px; height: 300px; padding: 50px; background-color: coral; background-clip: border-box; color: white; border: 5px dotted lightgrey; } </style> </head> <body> <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> </body> </html>
运行结果:
点击运行 »