编辑下面的代码:【加编码】
<html> <head> <style> div { width:100px; height:100px; background:red; color:white; -webkit-animation:mymove 2s infinite linear alternate; /* Chrome、Safari、Opera */ animation:mymove 2s infinite linear alternate; } @-webkit-keyframes mymove /* Chrome、Safari、Opera */ { to {-webkit-transform:rotateY(180deg);} } @keyframes mymove { to {transform:rotateY(180deg);} } </style> </head> <body> <p>勾选/取消勾选复选框,来改变旋转的 DIV 元素的 backface-visibility:</p> <div id="myDIV"><h1>Hello</h1></div> <input type="checkbox" onclick="myFunction(this)" checked>backface-visibility <script> function myFunction(x) { if (x.checked === true) { document.getElementById("myDIV").style.backfaceVisibility = "visible"; document.getElementById("myDIV").style.WebkitBackfaceVisibility = "visible"; // 针对 Chrome、Safari、Opera 的代码 } else { document.getElementById("myDIV").style.backfaceVisibility = "hidden"; document.getElementById("myDIV").style.WebkitBackfaceVisibility = "hidden"; // 针对 Chrome、Safari、Opera 的代码 } } </script> <p><strong>注意:</strong>Internet Explorer 9 及其之前的版本不支持 backface-visibility 属性。</p> </body> </html>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂