I'm trying to discover a way that doesn't use javascript that allows you to hover over the smaller divs (or images) to change the background of the larger div. Is this possible purely with HTML & CSS?
The example has 2 problems: 1. Only rolling over one of the divs works (because it's straight after) 2. When rolling over that div, the background of the main div reverts after moving the mouse off, so it's not a permanent change
I'm very curious and appreciate any advice here, thanks!
UPDATE: I've just created this: https://jsfiddle.net/ehzsmusr/
The backgrounds seem to change, but don't stay when you hover over something else. Can this be fixed?
#main {
width: 300px;
height: 200px;
background: red;
float: left;
}
.hover1 {
float: left;
background: blue;
width: 100px;
height: 75px;
}
.hover2 {
float: left;
background: green;
width: 100px;
height: 75px;
}
.hover1:hover + #main {
background: #ccc
}
.hover2:hover + #main {
background: #ccc
}
<div class='container'>
<div class='hover1'></div>
<div class='hover2'></div>
<div id='main'></div>
</div>