WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Adding a Character to Seperate Menu Items using CSS (but not on the submenus) (7 posts)

  1. invot
    Member
    Posted 1 year ago #

    I've been using that 'ol CSS trick (content: "";) to add a "|" after menu items in my menu. However, I have dropdown menus which look really silly with a divider. Here's my fancy-smancy CSS:

    #top-menu li:after {
    	content: "|";
    }
    
    #top-menu li:last-child:after {
    	content: "";
    }
    
    #top-menu ul li:children:after {
    	content: "";
    }

    So far, the first two functions are workin' without a hitch. That third fella is what's causing me to pull at my hair. Right now, it does the absolute equivalent of nothing. I've also tried:

    #top-menu li:children:after {
    	content: "";
    }

    This also did nothing.

    Anyone willing to offer up some enlightenment on this issue?

  2. Andrew Bartel
    Member
    Posted 1 year ago #

    Assuming you are targeting the correct elements, try content: none;.

    If that doesn't work please provide a link to your site.

  3. invot
    Member
    Posted 1 year ago #

    You are enforcing my fear that I am, indeed, targeting the wrong elements. Does anyone know the class/id of children list items(AKA, submenu items)?

    Here's the link you wanted Andrew. Thanks for the tip:

    http://bit.ly/RiPr61

  4. WPyogi
    Volunteer Moderator
    Posted 1 year ago #

    Looks like children is a class -- it's not a pseudo-element. So try changing the : to .

  5. invot
    Member
    Posted 1 year ago #

    WPyogi, if you happen to be a fairly attractive woman, I would kiss you. Otherwise, you get my thanks! Here's the working code:

    #top-menu li:after {
    	content: "|";
    }
    
    #top-menu li:last-child:after {
    	content: "";
    }
    
    #top-menu ul.children li:after {
    	content: none;
    }
  6. WPyogi
    Volunteer Moderator
    Posted 1 year ago #

    LOL - that's sweet! Glad to help - especially with such a lovely site and beautiful mission/sentiment. Best to all involved with the project.

  7. invot
    Member
    Posted 1 year ago #

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.