控制改变div样式

Original 2018-12-24 22:06:42 277
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>


Release Notes

Popular Entries