• Resolved Wolbee

    (@wolbee)


    My header menu has 4 buttons, which are highlighted when on the page (yay).
    One of those menu buttons has a sub menu (also yay).
    When on the parent page or any child page, the whole sub menu is highlighted (not yay).

    I can’t link my site, as I’m doing this offline, but here’s the (hopefully) relevant code:

    nav ul li.current-menu-item a:link,
    nav ul li.current-menu-item a:visited,
    nav ul li.current-page-ancestor a:link,
    nav ul li.current-page-ancestor a:visited {
      background-color: #006ec3;
      color: #FFF;
    }

    I’ve tried messing around with the code, including using nav ul li.menu-item ul li.current-menu-item a, but nothing I’m doing is working. I already spent way too long getting the sub menu to work properly, and now I’m getting frustrated at the CSS not playing ball.

Viewing 15 replies - 1 through 15 (of 16 total)
  • Wolbee

    Can you try this code?

    nav ul li.current-menu-item>a:link,
    nav ul li.current-menu-item>a:visited,
    nav ul li.current-page-ancestor>a:link,
    nav ul li.current-page-ancestor>a:visited {
      background-color: #006ec3;
      color: #FFF;
    }

    and do let me know if it works.

    Thread Starter Wolbee

    (@wolbee)

    Nope, that didn’t work…

    Wolbee

    I’ll need to see the HTML markup of that menu before making any other changes to what I’ve wrote, can you please provide that?

    Thread Starter Wolbee

    (@wolbee)

    It’s the About Us menu here (fair warning: it doesn’t look great – it’s a test site)

    Thread Starter Wolbee

    (@wolbee)

    To be honest, seeing as the menu on the right (that I created myself) is working how I want it, I might just rip out the WP-made one and do it myself…

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Which page do we have to go on to see the issue?

    Thread Starter Wolbee

    (@wolbee)

    Any of the About Us child pages

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    I went to one of the child pages just now and I’m not sure I see the issue. Here’s what I see: http://snag.gy/lgs0c.jpg – What do you mean by the whole menu is highlighted?

    Thread Starter Wolbee

    (@wolbee)

    Sorry, I forgot about that menu… you need to hover your mouse over the About Us in the top nav menu…

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    If you check your site with a web developer tool like Firebug, you can see the styles that are applying.
    E.g. this is applying the blue background:

    .site-header nav ul li.current-menu-item a:link,
    .site-header nav ul li.current-page-ancestor a:link {
        background-color: #006EC3;
    }

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Okay, let’s start with the basic selector first before you try to do 4 at once. Can you remove the 4 for now?

    Thread Starter Wolbee

    (@wolbee)

    I think I’m just going to create my own menu like I did on the right hand side… Thanks for trying to help though =)

    Wolbee

    Initially you provided me with half the information, there are multiple places you’ve added CSS for that menu
    Heres what I get it working with

    /*
    Theme Name: Gafina
    Author: Wolbee
    Version: 0.1
    */
    
    body {
    	font-family: Arial, sans-serif;
    	font-size: 14px;
    	color: #333;
    }
    
    a:link,
    a:visited {
    	color: #006ec3;
    }
    
    p {
    	line-height: 1.65em;
    	margin: 0 0 1em 0;
    }
    
    h1, h2, h3, h4, h5, h6 {
    	margin: 0 0 1em 0;
    	font-weight: normal;
    }
    
    /* General Layout */
    div.container {
    	max-width: 920px;
    	margin: 0 auto;
    	padding-left: 20px;
    	padding-right: 20px;
    }
    
    article.post {
    	border-bottom: 2px dotted #bbbbbb;
    	margin-bottom: 20px;
    }
    
    article.post:last-of-type {
    	border-bottom: none;
    }
    
    /* Aside Styles */
    article.post-aside,
    article.post-link {
    	font-size: 125%;
    	background-color: #FFF5CB;
    	padding: 20px 20px 1px 20px;
    	border-bottom: none;
    	border-radius: 5px;
    	box-shadow: 3px 3px 3px rgba(0, 0, 0, .1);
    }
    
    .mini-meta {
    	font-size: 68%;
    	margin: 0;
    	color: #777;
    	display: block;
    }
    
    .mini-meta a:link,
    .mini-meta a:visited {
    	color: #777;
    	text-decoration: none;
    }
    
    /* Link Post Format Styles */
    article.post-link {
    	padding: 0;
    	background-color: #E0EBFF;
    }
    
    article.post-link a {
    	display: block;
    	text-decoration: none;
    	padding: 20px;
    
    }
    
    /* Post Format Gallery Styles */
    article.post-gallery {
    	background-color: #222;
    	color: #FFF;
    	padding: 20px;
    	border: none;
    	border-radius: 5px;
    	box-shadow: 3px 3px 3px rgba(0, 0, 0, 0.1);
    }
    
    article.post-gallery img {
    	border: none!important;
    }
    
    article.post-gallery .wp-caption-text {
    	font-size: 86%;
    }
    
    article.post-gallery h2 {
    	text-align: center;
    }
    
    article.post-gallery h2 a {
    	color: #FFF;
    	text-decoration: none;
    	font-size: 130%;
    	text-transform: uppercase;
    	letter-spacing: 2px;
    }
    
    /* Header */
    .site-header {
    	border-bottom: 2px solid #DDD;
    	margin-bottom: 20px;
    	position: relative;
    }
    
    .site-header h1 {
    	margin: 0;
    	color: #006ec3
    }
    
    .site-header h5 {
    	margin: 0;
    }
    
    /* Navigation Menus */
    .site-nav ul {
    	margin: 0;
    	padding: 0;
    }
    
    .site-nav ul:before, .site-nav ul:after { content: ""; display: table; }
    .site-nav ul:after { clear: both; }
    .site-nav ul { *zoom: 1; }
    
    .site-nav ul li {
    	list-style: none;
    	float: left;
    }
    
    .site-nav ul li.menu-item ul li,
    .site-nav-2 ul li.menu-item ul li,
    .site-nav-2 ul li.menu-item-cart ul li {
    	display: none;
    }
    
    .site-nav ul li.menu-item:hover ul,
    .site-nav-2 ul li.menu-item:hover ul,
    .site-nav-2 ul li.menu-item-cart:hover ul {
    	position: absolute;
    	z-index: 99;
    }
    
    .site-nav-2 ul li.menu-item:hover ul {
    	right: -5px;
    }
    
    .site-nav ul li.menu-item:hover ul li,
    .site-nav-2 ul li.menu-item:hover ul li,
    .site-nav-2 ul li.menu-item-cart:hover ul li {
    	display: block;
    	float: none;
    	background-color: #FFF;
    	max-width: 96px;
    }
    
    .site-nav-2 ul li.menu-item:hover ul li {
    	max-width: 112px;
    }
    
    .site-nav-2 ul li.menu-item-cart:hover ul {
    	margin: 0;
    	padding: 0;
    	width: 150px;
    	border: 1px solid #BBB;
    }
    
    .site-nav ul li a:link,
    .site-nav ul li a:visited {
    	display: block;
    }
    
    .site-nav-2 ul li {
    	list-style: none;
    	float: right;
    }
    
    .cart-link-icon a {
    	background-image: url(images/cart.gif);
    	background-position: 5px 50%;
    	background-repeat: no-repeat;
    }
    
    /* Site Header Menu */
    .site-header nav {
    	margin-top: 30px;
    }
    
    .site-header nav ul li {
    	margin-right: 5px;
    }
    
    .site-header nav.site-nav-2 ul li:first-of-type {
    	margin-right: 0;
    }
    
    .site-header nav ul li>a:link,
    .site-header nav ul li>a:visited {
    	display: block;
    	padding: 10px 18px;
    	border: 1px solid #BBB;
    	border-top-left-radius: 15px;
    	border-top-right-radius: 15px;
    	border-bottom: none;
    	text-decoration: none;
    }
    
    .site-header nav ul li>a:hover {
    	background-color: #ECECEC;
    }
    
    .site-header nav ul li.current-menu-item a:link, .site-header nav ul li.current-menu-item a:visited, .site-header nav ul li.current-page-ancestor>a:link, .site-header nav ul li.current-page-ancestor>a:visited {
    	background-color: #006ec3;
    	color: #FFF;
    }
    
    .site-header nav ul li.menu-item ul li>a:link, .site-header nav ul li.menu-item ul li>a:visited {
    	border: 1px solid #BBB;
    	border-radius: 0;
    	text-align: center;
    }
    
    /* Homepage Post Columns */
    .home-columns {
    	padding-top: 30px;
    }
    
    .home-columns h2 {
    	margin-bottom: .7em;
    }
    
    .home-columns .one-half {
    	width: 45%;
    	float: left;
    	margin-right: 10%;
    }
    
    .home-columns .last {
    	margin-right: 0;
    }
    
    .home-columns .post-item {
    	border-bottom: 1px solid #DDD;
    	padding-bottom: 1px;
    	margin-bottom: 16px;
    }
    
    .home-columns .square-thumbnail {
    	float: left;
    	margin-right: 20px;
    	width: 120px;
    	height: auto;
    }
    
    .home-columns .post-item:last-of-type {
    	border-bottom: none;
    	padding-bottom: 0;
    	margin-bottom: 0;
    }
    
    .home-columns h4 {
    	margin-bottom: 3px;
    	font-weight: bold;
    }
    
    .home-columns h4 a {
    	text-decoration: none;
    }
    
    .home-columns h4 a:hover {
    	text-decoration: underline;
    }
    
    .subtle-date {
    	margin-left: 5px;
    	font-weight: normal;
    	font-size: 80%;
    	color: #FFF;
    	background-color: #BABABA;
    	text-shadow: 1px 1px 1px rgba(0, 0, 0, .33);
    	border-radius: 5px;
    	padding: 3px 7px;
    }
    
    .home-columns p {
    	font-size: 83%;
    }
    
    .btn-a,
    .btn-a:link,
    .btn-a:visited {
    	margin-top: 12px;
    	margin-bottom: 12px;
    	display: inline-block;
    	background-color: #006ec3;
    	text-decoration: none;
    	color: #FFF;
    	padding: 15px;
    	border-radius: 4px;
    	text-shadow: 1px 1px 0px rgba(0, 0, 0, .6);
    }
    
    .btn-a:hover {
    	background-color: #004C87;
    }
    
    .horiz-center {
    	display: block;
    	text-align: center;
    }
    
    /* Main Column */
    .main-column {
    	width: 66%;
    	float: left;
    }
    
    /* Side Column */
    .side-column {
    	width: 30%;
    	float: right;
    }
    
    .side-column .widget-item {
    	border-bottom: 1px solid #DDD;
    	padding-bottom: 20px;
    	margin-bottom: 20px;
    }
    
    h2.widget-title {
    	font-weight: normal;
    	margin-bottom: 10px;
    	color: #888;
    	text-transform: uppercase;
    	letter-spacing: 1px;
    	font-size: 138%;
    }
    
    .widget-item ul {
    	margin: 0;
    	padding: 0;
    }
    
    .widget-item ul li {
    	list-style-position: inside;
    	line-height: 1.65em;
    }
    
    .widget-item p:last-child {
    	margin: 0;
    }
    
    /* Footer Widget Areas */
    .footer-widgets {
    	padding-top: 40px;
    	margin-right: -40px;
    }
    
    .footer-widget-area {
    	width: 25%;
    	float: left;
    	padding-right: 40px;
    	box-sizing: border-box;
    }
    
    /* Footer */
    .site-footer {
    	overflow: hidden;
    	font-size: 84%;
    	margin-top: 30px 0 10px 0;
    	border-top: 2px solid #999;
    }
    
    /* Footer Nav Menu */
    .site-footer nav {
    	margin: 30px 0 10px 0;
    }
    
    .site-footer nav ul li {
    	margin-right: 10px;
    	padding-right: 10px;
    	border-right: 1px dotted #DDD;
    }/*
    
    .site-footer nav ul li:first-of-type {
    	padding-left: 10px;
    	border-left: 1px dotted #DDD;
    }
    
    /* Page Layout */
    article.page h2 {
    	font-size: 225%;
    	margin-bottom: 15px;
    }
    
    /* Clearfix */
    .clearfix:before, .clearfix:after { content: ""; display: table; }
    .clearfix:after { clear: both; }
    .clearfix { *zoom: 1; }
    
    /* Info Box Styles */
    div.info-box {
    	width: 30%;
    	float: right;
    	margin: 0 0 30px 30px;
    	padding: 20px;
    	background-color: #EEE;
    }
    
    div.info-box h4 {
    	margin-bottom: 6px;
    }
    
    div.info-box p {
    	font-size: 85%;
    }
    
    /* Children Links */
    .children-links {
    	margin-bottom: 20px;
    	font-size: 80%;
    }
    
    .children-links a:link,
    .children-links a:visited {
    	text-decoration: none;
    	padding-bottom: 2px;
    }
    
    .children-links ul {
    	float: left;
    }
    
    .children-links li {
    	margin-right: 20px;
    }
    
    .children-links .parent-link {
    	float: left;
    	margin-right: 20px;
    	padding-right: 20px;
    	border-right: 1px solid #DDD;
    	font-size: 120%;
    	font-weight: bold;
    }
    
    .children-links .parent-link a:link,
    .children-links .parent-link a:visited {
    	color: #333;
    }
    
    .children-links .current_page_item a:link,
    .children-links .current_page_item a:visited {
    	border-bottom: 1px solid #DDD;
    	color: #333;
    	cursor: default;
    }
    
    /* Post Styles */
    .post h2 {
    	margin-bottom: 0;
    }
    
    .post-info {
    	margin-top: 0;
    	font-size: 87%;
    	color: #999;
    }
    
    p.post-info a:link,
    p.post-info a:visited {
    	color: #999;
    }
    
    /* Image Styles */
    img {
    	max-width: 100%;
    	height: auto;
    	float: left;
    	padding: 10px;
    }
    
    .has-thumbnail {
    	position: relative;
    	padding-left: 200px;
    }
    
    .post-thumbnail {
    	position: absolute;
    	top: 0;
    	left: 0;
    }
    
    /* Search Form */
    div.hd-search {
    	float: right;
    }
    
    div.hd-search label {
    	position: absolute;
    	left: -9999px;
    }
    
    div.hd-search #searchsubmit {
    	background-color: #006ec3;
    	color: #FFF;
    	padding: 5px 14px;
    	border: none;
    	border-radius: 15px;
    	vertical-align: top;
    /*	margin-top: 20px; <- can't decide */
    }
    
    div.hd-search #s {
    	vertical-align: top;
    /*	margin-top: 20px; <- can't decide */
    	padding: 4px 0;
    	border-radius: 5px;
    	border: 1px solid #006ec3;
    }
    Thread Starter Wolbee

    (@wolbee)

    Sorry for only posting half the code – you can probably tell I’m new to this =) but seriously…? All I needed were a few “>” symbols? What does that even do?

    Also, do you know where I need to add a text-align: center; to align the widget in the cart drop down?

    Thanks so much =)

    Wolbee

    Always welcome 🙂

    Here’s more info about that selector
    http://www.w3schools.com/cssref/sel_element_gt.asp

    Try going through this whole page for more information about different types of selectors you can use in CSS
    http://www.w3schools.com/cssref/css_selectors.asp

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘Sub menu highlighting’ is closed to new replies.