css - Parent menu item hover while hovering submenu -
i have site http://jointviews.com/ header menu. header menu items , digital marketing has submenus under each. when hover dropdown submenu item parent menu background changing default one. should in hover position because here in submenus of particular menu item.
i tried giving
li.current-menu-ancestor { color: #fff; background: #f29919; }
but didn't work
please help. thanks.
edit: code
<ul id="menu-main" class="menu"><li id="menu-item-24" class="menu-item menu-item-type-custom menu-item-object-custom current-menu-item current_page_item menu-item-home menu-item-24"><a href="http://jointviews.com/">home</a></li> <li id="menu-item-25" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-25"><a href="http://jointviews.com/about-us/">about us</a> <ul class="sub-menu"> <li id="menu-item-267" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-267"><a href="http://jointviews.com/testimonials/">testimonials</a></li> </ul> </li> <li id="menu-item-27" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-27"><a href="http://jointviews.com/digital-marketing/">digital marketing</a> <ul class="sub-menu"> <li id="menu-item-33" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-33"><a href="http://jointviews.com/digital-marketing/seo/">seo</a></li> <li id="menu-item-34" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-34"><a href="http://jointviews.com/digital-marketing/social-media-marketing/">social media marketing</a></li> <li id="menu-item-30" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-30"><a href="http://jointviews.com/digital-marketing/email-marketing/">email marketing</a></li> <li id="menu-item-278" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-278"><a href="http://jointviews.com/digital-marketing/sem/">sem</a></li> <li id="menu-item-281" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-281"><a href="http://jointviews.com/digital-marketing/content-marketing/">content marketing</a></li> </ul> </li> <li id="menu-item-31" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-31"><a href="http://jointviews.com/portfolio/">portfolio</a></li> <li id="menu-item-258" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-258"><a href="http://jointviews.com/blog/">blog</a></li> <li id="menu-item-253" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-253"><a href="http://jointviews.com/contact-us/">contact us</a></li> </ul>
css:
ul.sub-menu{position:relative; z-index:40;} ul#menu-main ul { display: none; } ul#menu-main li:hover > ul { display: block;background-color: #fff; } ul#menu-main { position: relative; display: inline-table; top: 42px; position: relative; float:right; margin-bottom: 0px; clear: both; padding: 0 0 0 20px; background: transparent!important; list-style: none; height: 60px; font-family: bebasneueregular, helvetica, arial narrow, sans-serif; font-size: 18px; } ul#menu-main:after { content: ""; clear: both; display: block; } ul#menu-main li { float: left; line-height: 60px; z-index: 40; margin-left: 15px; } ul#menu-main li a:hover { color: #fff; background: #f29919; } ul#menu-main ul li{ border-bottom:1px solid #eee;} ul#menu-main ul li a:hover { color: #818181; background: #eee; } ul#menu-main li { display: block; font-family: bebasneueregular, helvetica, arial narrow, sans-serif; padding: 0 20px; color: #818181; text-decoration: none; } ul#menu-main ul { border-radius: 0px; padding: 0; position: absolute; top: 100%; } ul#menu-main ul li { float: none; position: relative; list-style:none; /*width: 180px;*/ line-height: 37px; margin-left: 0px; }ul#menu-main ul li:first-child{border-top: 1px solid white;} ul#menu-main ul ul li a:hover { color:white; } ul#menu-main ul ul { position: absolute; left: 100%; top:-1px; } ul#menu-main li.current-menu-item > a{ color: #fff; } ul#menu-main ul ul li:hover a{ color: #333333; }
change
ul#menu-main li a:hover { ... }
to
ul#menu-main > li:hover > { ... }
the >
operator choose first level children of corresponding element.
edit: edited change previous answer, current 1 better solution minimum effort.
edit2: removed element put there accidentally.
Comments
Post a Comment