返回div css......登陆

div css样式控制案例

Small morth2018-12-24 14:43:48322


<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>div -css样式控制案例</title>
<style>
#box{width:100px; height: 100px; background: pink;display="none"}
</style>
</head>
<body>
<div id="box"> 
</div>
<input type="button" value="变红" onclick="bred(this)">
<input type="button" value="变大" onclick="bda(this)">
<input type="button" value="变圆" onclick="byuan(this)">
<input type="button" value="还原" onclick="bhuan(this)">
<input type="button" value="隐藏" onclick="byin(this)">
<input type="button" value="显示" onclick="bxian(this)">

<script >
var box
window.onload=function() {
box=document.getElementById('box')//全局声明
}
function bred() {
box.style.background="red"//变红
}
function bda() {
box.style.width="120px"
box.style.height="120px"//变大
}
function byuan() {
box.style.borderRadius="60px"//变圆
}
function bhuan() {
box.style.borderRadius="0px"//还原
box.style.width="100px"//还原
box.style.height="100px"//还原
box.style.background="pink"//还原
}
function byin() {
box.style.display="none"//隐藏
}
function bxian() {
box.style.display="block"//显示
}
</script>
</body>
</html>

QQ截图20181224144321.png

最新手记推荐

• 用composer安装thinkphp框架的步骤• 省市区接口说明• 用thinkphp,后台新增栏目• 管理员添加编辑删除• 管理员添加编辑删除

全部回复(0)我要回复

暂无评论~
  • 取消回复发送