请告诉我如何以最正确的方式完成这件事。
HTML:
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;
}
我希望能够在用户打开/关闭红色
,绿色
, 或 蓝色
div(当它们可见时)时,向 fixed-red/green/blue
div 中添加/删除红/绿/蓝-active
类,这样当用户访问它们时 ,小的 div 会分别以大的显示div的颜色进行高亮。
谢谢!
on
,但我不知道如何检查它们是否可见。 - user7362793