請告訴我如何以最正確的方式進行此操作。當特定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