been designing a nav bar with child links with pure css for my new script but also for abit of fun.
and thought i would share my workings here incase someone else wanted a pure css solution without js.
heres what i got so far.
css
HTML
DEMO
i would like to attempt to add sub child links also. but atm having issues solving this.
if anyone wants to attempt it and solve it before me. please let me know thanks.
and thought i would share my workings here incase someone else wanted a pure css solution without js.
heres what i got so far.
css
Code:
body {background-color:#111111; font-family:Verdana, sans-serif; font-size:0.8em; color:#408080;} a {color:#408080;} .nav {background-color:#1a1a1a; border:1px solid #408080; margin:5px; border-radius:7px;} .nav ul {margin:0; padding:0;} .nav ul li {display:block; float:left; position:relative;} .nav ul li:hover {background-color:#0a0a0a;} .nav ul li:hover > ul {display:block; position:absolute;} .nav ul li a {text-decoration:none; color:#408080;} .nav ul li ul {border-radius:7px; border:1px solid #408080; background-color:#1a1a1a; display:none; left:0px; width:250px; margin-top:6px;} .nav ul li ul li {width:241px;} .nav ul li ul li:hover {width:241px; background-color:#0a0a0a;} .nav-first-parent-link {padding:6px 8px 6px; border-right:1px solid #408080; border-radius:7px 0px 0px 7px;} .nav-middle-parent-link {border-right:1px solid #408080; padding:6px 8px 6px;} .nav-last-parent-link {padding:6px 8px 6px; border-right:1px solid #408080; border-radius:0px 7px 7px 0px;} .nav-single-child-link {padding:4px; border-radius:7px 7px 7px 7px;} .nav-first-child-link {padding:4px; border-radius:7px 7px 0px 0px; border-bottom:1px solid #408080;} .nav-middle-child-link {border-bottom:1px solid #408080; padding:4px;} .nav-last-child-link {padding:4px; border-radius:0px 0px 7px 7px;} .nav-padder {height:0px; clear:both;}
Code:
<div class="nav"> <ul> <!-- Show use of a parent with no child --> <li class="nav-first-parent-link"> <a href="#">Amazing</a> </li> <!-- Show use of a parent with a single child --> <li class="nav-middle-parent-link"> <a href="#">CSS</a> <ul> <li class="nav-single-child-link"><a href="#">More CSS Links</a></li> </ul> </li> <!-- Show use of a parent with 2 childs --> <li class="nav-middle-parent-link"> <a href="#">Dropdown</a> <ul> <li class="nav-first-child-link"><a href="#">More Dropdown Links</a></li> <li class="nav-last-child-link"><a href="#">More Dropdown Links</a></li> </ul> </li> <!-- Show use of a parent with 3 childs or more --> <li class="nav-middle-parent-link"> <a href="#">Menu</a> <ul> <li class="nav-first-child-link"><a href="#">More Menu Links</a></li> <li class="nav-middle-child-link"><a href="#">More Menu Links</a></li> <li class="nav-last-child-link"><a href="#">More Menu Links</a></li> </ul> </li> </ul> <!-- A Padder To Clear Floats, Nothing More --> <div class="nav-padder"></div> </div>
i would like to attempt to add sub child links also. but atm having issues solving this.
if anyone wants to attempt it and solve it before me. please let me know thanks.
Comment