源代码:
下载代码
AI 编程工具
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>菜鸟教程(runoob.com)</title> <style> #myDIV { width: 200px; height: 200px; background-color: coral; text-align: center; } </style> </head> <body> <h1>使用 JavaScript 修改 clip-path</h1> <p>点击以下按钮剪辑 DIV 元素:</p> <button onclick="myFunction()">点我</button> <div id="myDIV"> <br><br> <h1>RUNOOB</h1> </div> <script> function myFunction() { document.getElementById("myDIV").style.clipPath = "circle(50%)"; } </script> </body> </html>
运行结果: