div改变css的案列

Original 2018-12-10 21:26:07 280
abstract:总结:我在这颗学习到了用js控制div里面的css的效果。也做了一个小小的案列<!DOCTYPE html><html><head><meta charset="UTF-8"><title>Document</title><style type="text/css">#ait

总结:我在这颗学习到了用js控制div里面的css的效果。也做了一个小小的案列

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>Document</title>

<style type="text/css">

#ait{width: 100px;height: 100px;background: #000;


}

</style>

</head>

<body>

<script type="text/javascript">

var ait

window.onload=function(){

ait=document.getElementById("ait")

}

function ait_yx(){

ait.style.borderRadius="50px"

ait.style.width="100px"

ait.style.height="100px"

 

}

function ait_k(){

ait.style.borderRadius="0px"

ait.style.width="600px"



}

function ait_bs(){

ait.style.background="red"

ait.style.borderRadius="0px"

}

function ait_yc(){

ait.style.display="none"

}

function ait_xs(){

ait.style.display="block"

ait.style.height="100px"

ait.style.width="100px"

ait.style.background="#ccc"


}

function ait_csh(){

ait.style.height="100px"

ait.style.width="100px"

ait.style.background="#000"

ait.style.borderRadius="0px"

}


</script>

<div id="ait"></div>


<input type="button" value="变宽" onclick="ait_k()">

<input type="button" value="变圆形" onclick="ait_yx()">

<input type="button" value="变色" onclick="ait_bs()">

<input type="button" value="隐藏" onclick="ait_yc()">

<input type="button" value="显示" onclick="ait_xs()">

<input type="button" value="初始化" onclick="ait_csh()">



</body>

</html>


Correcting teacher:韦小宝Correction time:2018-12-11 09:21:11
Teacher's summary:写的很不错!学习就是这样,学习到了小知识要运用起来!课后多练习哦!

Release Notes

Popular Entries