Results 1 to 4 of 4

Thread: Dropdown Menu - Submenu not lining up

  1. #1

    Thread Starter
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,760

    Dropdown Menu - Submenu not lining up

    I'm re-working my dropdown menu from earlier post and I'm running into the issue where my submenu is not lining up with it's top-level parent. Here is my JSFiddle. What I'm finding is that it's because of this line:
    Code:
    .menubar li {
        display: inline-block;
        padding: 0 15px;
    }
    Whenever I set the top-level parent's left and right padding to 15 pixels, it throws off the positioning of my submenu. How can I make to it where the submenu's left will be lined up with it's top-level parent's left?
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  2. #2
    Frenzied Member tr333's Avatar
    Join Date
    Nov 2004
    Location
    /dev/st0
    Posts
    1,605

    Re: Dropdown Menu - Submenu not lining up

    https://jsfiddle.net/j6p1an97/1/

    I split the ".menubar li" selector into two, so you can add extra specificity with the child selector on the inline-block. You are already specifying display: block for the submenu li further down the styles so you don't want this previous selector setting it to inline-block. You wouldn't have noticed this since the later more-specific definition (block) overrides the earlier definition (inline-block).

    As for the padding issue, I've added a negative margin-left of 15px to the submenu to shift it left by 15px.

    EDIT: I couldn't see what you are using to display the caret symbol. I would suggest something like Font Awesome; specifically caret-down or angle-down.
    Last edited by tr333; Feb 19th, 2015 at 06:50 PM.
    CSS layout comes in to the 21st century with flexbox!
    Just another Perl hacker,

  3. #3

    Thread Starter
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,760

    Re: Dropdown Menu - Submenu not lining up

    Alright, thank you so much.

    PS - Sorry for the late reply.
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  4. #4
    Frenzied Member tr333's Avatar
    Join Date
    Nov 2004
    Location
    /dev/st0
    Posts
    1,605

    Re: Dropdown Menu - Submenu not lining up

    CSS layout comes in to the 21st century with flexbox!
    Just another Perl hacker,

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width