js改变div属性
来源:互联网 发布:瑞中数据官网 编辑:程序博客网 时间:2024/06/10 12:05
<!DOCTYPE html><html><head><meta charset="UTF-8"><title></title><style type="text/css">body{margin: 0px;padding: 0px;}#show{background: red;width: 100px;height: 50px;float: left;margin-top: 15px;margin-left: 10px;color: white;display: block;float: left;}h1{float: left;}#link{width: 200px;height: 200px;border: 5px solid black;background: gainsboro;float: left;position:absolute;top: 100px;left: 100px;}#bg{position: absolute;display:none;left:0;top:0;z-index:10;background:#DCDBDC;-moz-opacity: 0.8;opacity:.80;filter: alpha(opacity=80);}#sz{position: absolute;display:none;width:500px;height:300px;left:50%;top:40%;z-index:11;background:#B8F764; }#sz ul{margin: 0px;padding: 0px;width: 240px;height: 220px;float: left;}#sz ul li{line-height: 30px;text-align: center;width: 240px;height: 80px;list-style:none;}#sz div div{margin-left: 20px;line-height: 30px;text-align: center;width: 50px;height: 40px;float: left;}#sz a{float: left;text-decoration: none;}</style></head><body><h1>请为下面的div设置样式:</h1><button id="show" onclick="show()">点击设置</button><div id="link"></div><div id="bg" > </div><div id="sz" ><div><ul><li>请选择背景颜色:</li><li>请选择宽度(px):</li><li>请选择高度(px):</li></ul><ul style="float: right;"><li><div id="red" style="background: green;">红色</div><div id="yellow" style="background: deepskyblue;">黄色</div><div id="blue" style="background: pink;">蓝色</div></li><li><div id="w200" style="background: whitesmoke;">200</div><div id="w300" style="background: whitesmoke;">300</div><div id="w400" style="background: whitesmoke;">400</div></li><li><div id="h200" style="background: whitesmoke;">200</div><div id="h300" style="background: whitesmoke;">300</div><div id="h400" style="background: whitesmoke;">400</div></li></ul></div><div><a href="#" onclick="returns()">恢复</a><a href="javascript:void(0)" onclick="closeBox()">关闭</a></div></div><script>var link=document.getElementById("link");function closeBox(){bg.style.display="none";sz.style.display="none";}function show(){var bg=document.getElementById("bg");var sz=document.getElementById("sz");bg.style.width=document.body.scrollWidth + "px";bg.style.height=document.body.scrollHeight+"px";bg.style.display="block";sz.style.display="block";}function returns(){link.style.width="200px";link.style.height="200px";link.style.background="gainsboro";}var red=document.getElementById("red");var yellow=document.getElementById("yellow");var blue=document.getElementById("blue");var w200=document.getElementById("w200");var w300=document.getElementById("w300");var w400=document.getElementById("w400");var h200=document.getElementById("h200");var h300=document.getElementById("h300");var h400=document.getElementById("h400");red.onmouseover=function(){link.style.background="red";red.style.background="red";}yellow.onmouseover=function(){link.style.background="yellow";yellow.style.background="yellow";}blue.onmouseover=function(){link.style.background="blue";blue.style.background="blue";}w200.onmouseover=function(){link.style.width="200px";w200.style.background="bisque";}w300.onmouseover=function(){link.style.width="300px";w300.style.background="bisque";}w400.onmouseover=function(){link.style.width="400px";w400.style.background="bisque";}h200.onmouseover=function(){link.style.height="200px";h200.style.background="bisque";}h300.onmouseover=function(){link.style.height="300px";h300.style.background="bisque";}h400.onmouseover=function(){link.style.height="400px";h400.style.background="bisque";}</script></body></html>
阅读全文
0 0
- js改变div属性
- JS改变Div样式属性示例
- js改变div的class属性
- js改变div宽度
- js 改变div 背景图片
- 用js实现改变随意改变div属性style的名称和值的结果
- js改变div宽高
- js改变DIV的高度
- js改变标签得属性
- 动态改变div的z-index属性
- JS操作DIV全属性
- JS操作DIV全属性
- js 动态改变div内部布局
- js 如何动态改变div的位置
- rails4 ,用js改变div的背景图片
- JS实现拖动div改变大小
- js innerHTML 改变div内容的方法
- js实现div动态改变大小
- C++风格_缺省参数
- NASM与MASM的区别(不断更新中,参考NASM中文手册)
- 滚动条
- 技术大牛养成指南,一篇不鸡汤的成功学实践
- Ubuntu 17.10 初体验
- js改变div属性
- python 列表解析
- 10.22 2017-57级模拟题 二分+并查集+MST+递推+DP+毒瘤noip
- 输入一个十进制整数,设计递归函数,将该整数转化为一个二进制数。 思考: 如何将一个十进制数转化成一个8进制和16进制数。
- C++风格_变长数组和alloca()
- php curl实现图片下载
- 用Intellij IDEA和SBT建立scala时,新手容易遇到的一些麻烦
- Linux入门学习Make
- 使用更小卷积核的作用