0

I have ceated a dropdown menu using the following css

.menu li ul {display: none;}
.menu li:hover > ul {display: block;}

But the problem is whenever the menu dropsdown the content below shifts down. How can I prevent that.

1 Answer 1

2

You can prevent that by positioning the sub menu absolute.

.menu li ul {display: none; position: absolute; }

You also have to set

.menu { position: relative; }

as said in the comment by Tae. If you do not, the sub menu will probably set to the top left corner of the page.

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

1 Comment

Don't forget to make the menu position:relative;, or the submenu will be positioned relative to the browser window.

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.