HTML css/style/關鍵字位置不同
阿新 • • 發佈:2017-06-13
cit cti lac height pin sna itl set document
<head> <meta charset="UTF-8"> <title>Title</title> <style> .box{ background-color:red; width: 100px; height: 100px; margin-top: 35px; } </style> </head> <body> <div class="box"> </div> <script> var box=document.getElementsByClassName("box")[0]; box.onclick=function() { box.style.backgroundColor = "blue"; } </script> </body> </html>
兩邊的backgroundcolor 關鍵字名字不同
body style 裏的寫法
<head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <div style="width: 100px; height: 100px;background-color:pink;">
</div> <script> var div= document.getElementsByTagName("div")[0]; div.onmouseover=function(){ div.style.width="200px"; div.style.height="200px"; div.style.backgroundColor="black"; div.style.opacity="0.2"; div.style.filter="alpha(opacity=20)"; } </script> </body> </html>
HTML css/style/關鍵字位置不同