I am attempting to design a pure CSS on-hover horizontal menu.
I have made some progress on my design, as shown in http://jsfiddle.net/dq8z192L/11/
The goal is to have a menu that expands horizontally when hovered over. Each tab reveals a set of links below it.
I then modified it to create http://jsfiddle.net/dq8z192L/13/. The objective was to display the links of the leftmost tab by default and show the links of other tabs on hover.
However, I encountered an issue with the CSS2 code. Despite including the
.linkgroup2:hover , .linkgroup3:hover { display:block; }
line in both CSS1 and CSS2, I am unable to access the sets of links by hovering over the HEADING 02 or HEADING 03 tabs.
I am puzzled by this and would appreciate any guidance on what I might be doing wrong.
NOTE: The HTML code remains the same for both cases.
HTML
<div>
<div id="c1">HEADING 01</div>
<div id="c2">HEADING 02</div>
<div id="c3">HEADING 03</div>
<ul class="linkgroup1">
<li><a href="#" title="">link 01</a></li>
<li><a href="#" title="">link 02</a></li>
<li><a href="#" title="">link 03</a></li>
</ul>
<ul class="linkgroup2">
<li><a href="#" title="">link 04</a></li>
<li><a href="#" title="">link 05</a></li>
<li><a href="#" title="">link 06</a></li>
</ul>
<ul class="linkgroup3">
<li><a href="#" title="">link 07</a></li>
<li><a href="#" title="">link 08</a></li>
<li><a href="#" title="">link 09</a></li>
<li><a href="#" title="">link 10</a></li>
</ul>
</div>
<div><p>some stuff here ...</p></div>
CSS 1 (partially successful CSS)
#c1, #c3 { width: 33%; float:left; background-color:#ef6;}
#c2 { width: 34%; float:left; background-color:#eee; }
ul { list-style:none; }
li { display: inline; }
.linkgroup1 , .linkgroup2 , .linkgroup3 { display:none; }
#c1:hover ~ .linkgroup1 { display:block; }
#c2:hover ~ .linkgroup2 { display:block; }
#c2:hover ~ .linkgroup1 { display:none; }
#c2:hover ~ .linkgroup3 { display:none; }
#c3:hover ~ .linkgroup3 { display:block; }
#c3:hover ~ .linkgroup1 { display:none; }
#c3:hover ~ .linkgroup2 { display:none; }
.linkgroup1, .linkgroup2 , .linkgroup3 { padding-top:3em; }
.linkgroup1:hover , .linkgroup2:hover , .linkgroup3:hover { display:block; }
.linkgroup1 { background-color:#6e7fe4; }
.linkgroup2 { background-color:#f4e32b; }
.linkgroup3 { background-color:#b3ffff; }
CSS 2 (unsuccessful CSS)
#c1, #c3 { width: 33%; float:left; background-color:#ef6;}
#c2 { width: 34%; float:left; background-color:#eee; }
ul { list-style:none; }
li { display: inline; }
.linkgroup2 , .linkgroup3 { display:none; }
#c2:hover ~ .linkgroup1 { display:none; }
#c2:hover ~ .linkgroup3 { display:none; }
#c2:hover ~ .linkgroup2 { display:block; }
#c3:hover ~ .linkgroup1 { display:none; }
#c3:hover ~ .linkgroup2 { display:none; }
#c3:hover ~ .linkgroup3 { display:block; }
.linkgroup1, .linkgroup2 , .linkgroup3 { padding-top:3em; }
.linkgroup2:hover , .linkgroup3:hover { display:block; }
.linkgroup1 { background-color:#6e7fe4; }
.linkgroup2 { background-color:#f4e32b; }
.linkgroup3 { background-color:#b3ffff; }