Please tell me how I can do this in the most correct way.
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; }
I want to add / remove the red/green/blue-active class in the fixed-red/green/blue div when the user turns on the red , green or blue div (when they are visible), so the small divs will be correspondingly highlighted in the color of the large display screen when the user will be on them.
Thanks!
source share