返回改变div样式...登陆

改变div样式

离歌浅唱醉人心丶2019-01-16 22:29:52285

<!doctype html>
<html lang="en">
<head>
   <meta charset="UTF-8">
   <title>改变div样式</title>
   <style>
#box{
width: 200px;
height: 200px;
background-color: lightcoral;
margin: 20px 60px;
transition: 0.6s;
       }
</style>
</head>
<body>
<div id="box"></div>
<button onclick="height()">变高</button>
<button onclick="width()">变宽</button>
<button onclick="color()">变色</button>
<button onclick="circular()">变圆</button>
<button onclick="hide()">隐藏</button>
<button onclick="show()">显示</button>
<button onclick="resetting()">重置</button>
<script>
var box;
window.onload = function () {
box = document.getElementById('box');
   };
function width() {
box.style.width = '600px';
   }
function height() {
box.style.height = '600px';
   }
function color() {
box.style.backgroundColor = '#ccc';
   }
function circular() {
box.style.borderRadius = '50%'
}
function resetting() {
box.style.width = '200px';
box.style.height = '200px';
box.style.display = 'block';
box.style.borderRadius = '0';
box.style.backgroundColor = 'lightcoral';
   }
function hide() {
box.style.display = 'none';
   }
function show() {
box.style.display = 'block';
   }
</script>
</body>
</html>

演示地址 -> http://47.107.64.136/JS/4/

最新手记推荐

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

全部回复(0)我要回复

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