0

I seem to be having a problem with my Wordpress CSS Menu. I am trying to create a dropdown element in the menu, which is conveniently wrapped in a div automatically called "sub-menu".

When normal, the menu looks like this: normal menu

However, when I try to access the drop-down menu under "Photography", this happens:


enter image description here

I have tried everything and am unable to get it to correctly show up under Photography. Any help would be much appreciated:

#header li ul.sub-menu {
display:none;
position: absolute;
top: 10px;
left: 50%;
width: auto;
}

#header li:hover ul.sub-menu {
display:block;
}

1 Answer 1

1

You need to make sure the container element (#header li) is set to a position as well. I would use relative becasue it will (hopefully) not break other positioning:

#header li {
position: relative;
}

#header li ul.sub-menu {
display:none;
position: absolute;
top: 10px;
left: 50%;
width: auto;
}

header li:hover ul.sub-menu {
display:block;
}

Absolute elements will position itself based on the nearest parent who's position is set explicitly.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.