请告诉我如何以最正确的方式进行此操作。当特定div可见时更改颜色
HTML:
<div id="fixed-red" class="fixed-red"></div>
<div id="fixed-green" class="fixed-green"></div>
<div id="fixed-blue" class="fixed-blue"></div>
<div id="red" class="red"></div>
<div id="green" class="green"></div>
<div id="blue" class="blue"></div>
CSS:
html,body{
height:100%;
}
.fixed-red,.fixed-green,.fixed-blue{
width:30px;
height:30px;
position:fixed;
top:10px;
left:10px;
background:#333;
}
.fixed-green{
top:50px;
}
.fixed-blue{
top:90px;
}
.red-active{
background:#f00;
}
.green-active{
background:#0f0;
}
.blue-active{
background:#00f;
}
.red,.green,.blue{
width:100%;
height:100%;
}
.red{
background:#900;
}
.green{
background:#090;
}
.blue{
background:#009;
}
我想添加/当用户开启/关闭red
,,或blue
的div删除red/green/blue-active
类的fixed-red/green/blue
的div(当它们可见时),所以当用户在其上时,小div将分别用大的显示div的颜色突出显示。
谢谢!
工作拨弄我想添加事件'的on',在'red','green'和'蓝'大分区,但我不知道如何检查它们是否可见 – user7362793