abstract:<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>控制改變div樣式</title> <style> .conent{width: 800px;margin:0 auto;} .an{t
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>控制改變div樣式</title> <style> .conent{width: 800px;margin:0 auto;} .an{text-align: center;margin-top: 20px;} #box{height: 200px;width: 200px;background: #e3e3e3;margin:0 auto;} </style> <script type="text/javascript"> var box window.onload=function(){ box=document.getElementById('box') } function box_h () { box.style.height="400px" } function box_w(){ box.style.width="400px" } function box_color(){ box.style.background="red" } function box_cz(){ box.style.height="200px" box.style.width="200px" box.style.background="#e3e3e3" } function box_none(){ box.style.display="none" } function box_block(){ box.style.display="block" } </script> </head> <body> <div> <div id="box">控制改變div樣式</div> <div> <input type="button" value="變高" onclick="box_h()"> <input type="button" value="變寬" onclick="box_w()"> <input type="button" value="變色" onclick="box_color()"> <input type="button" value="重置" onclick="box_cz()"> <input type="button" value="隱藏" onclick="box_none()"> <input type="button" value="顯示" onclick="box_block()"> </div> </div> </body> </html>
Correcting teacher:韋小寶Correction time:2018-12-25 09:40:08
Teacher's summary:不錯不錯!現(xiàn)在是不是發(fā)現(xiàn)前端還是比較有意思的!后面還可以做成動畫哦!