I got a menu with childs.
I want to change the background on parent and child when a child is picked, and only change the background on parent when parent is picked.
I've searched for it, but it seems like it just wont work. And i know that many have asked this question. I've tried doing it with jquery, but i can't get it right.
My code so far is following:
HTML
<div class="menu">
<ul>
<li><a id="home" href="index.php">Home</a></li>
<li><a href="Programming.php">Programming Language</a>
<ul>
<li><a href="Programming_HTML.php">HTML</a></li>
</ul>
</li>
<li><a href="Project.php">Project</a>
<ul>
<li><a href="Project_Calculator.php">Calculator</a></li>
<li><a href="Project_ImageSlider.php">Image Slider</a></li>
</ul>
</li>
</ul>
</div>
CSS
.menu { font-family: arial, sans-serif; width:1190px; text-align: center; font-size:11px; z-index:100;}
.menu ul li a, .menu ul li a:visited {display:block; text-decoration:none; color:#000; height:51px; text-align:center; color:#000; background:#ddd; line-height:50px; font-size:15px; overflow:hidden; box-shadow:inset 0 0 10px #000000;}
.menu ul {padding:0; margin:0; list-style: none;}
.menu ul li {float:left; position:relative; background: #F16529; width: 238px;}
.menu ul li ul {display: none;}
.menu ul li ul li a{ background:#36f;}
.menu ul li ul li{margin-left: 10px; width: 215px; border-left: 1px solid #000; border-bottom: 1px solid #000; }
.menu ul li a{border-right: 1px solid #000;}
#home{border-left: 1px solid #000;}
.menu ul li:hover a {color:#fff; background:#36f;}
.menu ul li:hover ul {display:block; position:absolute; top:51px; left:0;}
.menu ul li:hover ul li ul {display: none;}
.menu ul li:hover ul li a {display:block; background:#ddd; color:#000;}
.menu ul li:hover ul li a:hover {background:#FF6A00; color:#fff;}
.menu ul li:hover ul li:hover ul {display:block; position:absolute; left:105px; top:0;}
.menu ul li:hover ul li:hover ul.left {left:-105px;}
When it comes to the jquery, i'm thinking clickfunction.
I also know that i need to add an active class in the css.
You are welcome to check the menu out, it goes great with this div, around it.
#top-wrap{float:center; width: 100%; height: 51px; display: block; background-color: #000; -webkit-box-shadow: inset 0 10px 15px rgba(0, 0, 0, 0.1); -moz-box-shadow: inset 0 10px 15px rgba(0, 0, 0, 0.1); box-shadow: inset 0 10px 15px rgba(255, 255, 255, 0.6);}
i got this example, but i can't get it working with my code, and also there is heavy much css! – user2060000 Oct 30 '13 at 19:11