<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.box {
width: 600px;
height: 500px;
border: 2px solid black;
position: relative;
}
.box1 {
width: 200px;
height: 140px;
border: 1px solid #ccc;
}
.btn {
position: absolute;
top: 20px;
right: 50px;
}
p{
font-size: 20px;
font-weight: bold;
}
.box2{
width: 240px;
height: 380px;
position: absolute;
top:20px;
right: 30px;
display: none;
background-color: #fff;
padding: 10px;
}
.box3{
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
span{
width: 80px;
height: 30px;
border: 2px solid #ccc;
line-height: 30px;
margin-bottom: 10px;
text-align: center;
}
</style>
</head>
<body>
<div class="box">
<div class="box1"></div>
<button class="btn">点击显示div样式</button>
<div class="box2">
<p>大小</p>
<div class="box3">
<span>300*300</span>
<span>200*300</span>
<span>300*200</span>
<span>100*300</span>
</div>
<p>颜色</p>
<div class="box3">
<span>red</span>
<span>yellow</span>
<span>blue</span>
<span>pink</span>
</div>
<button>确定</button>
<button>取消</button>
</div>
</div>
<script>
var box=document.getElementsByTagName("div");
var btn=document.getElementsByTagName("button");
var ospan=document.getElementsByTagName("span");
console.log(ospan[0]);
btn[0].οnclick= function(){
box[0].style.backgroundColor = '#999999';
box[2].style.display = "block";
}
ospan[0].onmouseover = function(){
box[1].style.width = '300px'
box[1].style.height = "300px"
}
ospan[1].onmouseover = function(){
box[1].style.width = '200px'
box[1].style.height = "300px"
}
ospan[2].onmouseover = function(){
box[1].style.width = '300px'
box[1].style.height = "200px"
}
ospan[3].onmouseover = function(){
box[1].style.width = '100px'
box[1].style.height = "300px"
}
ospan[4].onmouseover = function(){
box[1].style.backgroundColor= ospan[4].innerHTML
}
ospan[5].onmouseover = function(){
box[1].style.backgroundColor= ospan[5].innerHTML
}
ospan[6].onmouseover = function(){
box[1].style.backgroundColor= ospan[6].innerHTML
}
ospan[7].onmouseover = function(){
box[1].style.backgroundColor= ospan[7].innerHTML
}
btn[1].onclick = function(){
box[0].style.backgroundColor = ""
box[2].style.display = 'none'
}
btn[2].onclick = function(){
box[0].style.backgroundColor = ""
box[2].style.display = 'none'
box[1].style = ""
}
</script>
</body>
</html>