- This topic is empty.
-
AuthorPosts
-
August 5, 2014 at 5:56 am #177687
Sean
ParticipantHello! I’m attempting to make a full-width, CSS drop-down menu, where the sub-menu ‘ul’ items are offset slightly to the left of their parent.
Here’s the goal, from my designer: http://i.imgur.com/R5rLdqx.jpg
And what I’ve made, so far: http://i.imgur.com/GqjwqVl.png
I’ve run into two problems:
- I have to set a width on my sub-menu
ul
(in the CodePen link below, 200px), as it doesn’t stretch to fit the ‘li’ elements within, and; - I’m stumped when it comes to making the sub-menu stretch to fill the width of the screen, as in the designer’s image.
Here it is on CodePen: http://codepen.io/anon/pen/aKfbI
Thanks! Love this forum.
August 5, 2014 at 8:20 am #177702Paulie_D
MemberI’m sure I’m missing something…this should be easy but I’m having trouble with it.
Giving the submenu an absolute position and centering the internal list items under the parent
li
is tricky.August 5, 2014 at 8:37 am #177706Sean
Participant@Soronbe: It’s like magic!
I see you added ‘margin: 0 -9999px; padding: 0 9999px;’ to
.main-navigation ul li:hover > ul
Everything works great on CodePen, but on my development site the
li
items in the sub-menu are vertical, not horizontal. The sub-menuul
seems to be taking its width from the parentli
.I’ve tried to see if other CSS on the site is affecting it, but no dice yet.
August 5, 2014 at 10:06 am #177724Sean
ParticipantSorry: The development site is running on a localhost, so I have no link to send!
BUT: @Atelierbram’s implementation of @Soronbe’s idea (link) is almost there.
It seems the
box-sizing: inherit
in the reset is fixing the problem with the vertical/horizontal resizing, though it’s had the unintended consequence of pushing the menu up to the top of the page.Here’s a revised pen that includes my entire stylesheet: http://codepen.io/anon/pen/aplcz
August 5, 2014 at 10:50 am #177738Sean
Participant@Atelierbram Aha. WordPress automatically outputs that code so I had to figure out how to get rid of it. Done.
The menu works! Amazing.
BUT: The
* {box-sizing:inherit}
is somehow screwing up formatting on a few other parts of the site. (I see my CSS, which is pulled from Underscores.me has abox-sizing: border-box
reset.)Is there a way to isolate your reset so it applies only to the nav menu, or should I re-adjust the rest of the site to compensate for the change?
(Apologies: I don’t know a lot about border-box)
August 5, 2014 at 11:15 am #177748Sean
ParticipantYou’re a genius! Thank you.
- I have to set a width on my sub-menu
-
AuthorPosts
- The forum ‘CSS’ is closed to new topics and replies.