运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
转到 Spaces
<!DOCTYPE html> <html> <head> <style> #DIV1 { height: 200px; width: 200px; margin: auto; border: 1px solid black; position: relative; } #DIV2 { width: 150px; height: 150px; border: 1px solid black; background-color: coral; scale: 1 1; } #DIV2original { position: absolute; z-index: -1; opacity: 0.5; width: 150px; height: 150px; border: 1px dashed grey; background-color: lightgrey; } </style> </head> <body> <h1>Change scale property with JavaScript</h1> <p>Click the "Try it" button to set new scale property for both the x-axis and the y-axis:</p> <p><b>Note: </b>The grey DIV element indicates where the DIV2 element would be without the change in scale property.</p> <button onclick="myFunction()">Try it</button> <div id="DIV1">DIV1 <div id="DIV2original">DIV2</div> <div id="DIV2">DIV2</div> </div> <script> function myFunction() { document.getElementById("DIV2").style.scale = "2 0.7"; } </script> </body> </html>