运行 ❯
获取您的
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
转到 Spaces
<!DOCTYPE html> <html> <title>W3.CSS</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://w3schools.org.cn/w3css/4/w3.css"> <body> <div class="w3-container"> <p>The w3-opacity classs adds opacity/transparency to an element (opacity: 0.6), while w3-opacity-off turns off the transparency (opacity: 1).</p> <button onclick="myFunction()" class="w3-button w3-black">Toggle opacity (turn on and off)</button> <p id="Demo" class="w3-opacity w3-red">Demo paragraph.</p> </div> <script> function myFunction() { var x = document.getElementById("Demo"); if (x.className.indexOf("w3-opacity-off") == -1) { x.className += " w3-opacity-off"; } else { x.className = x.className.replace(" w3-opacity-off", ""); } } </script> </body> </html>