0

Trying to practice making a slide down menu with html and css.

My only issue is with how the list items overlaps with the menu option.

How do i get the menu to slide behind the menu option?

HTML

<div class="container">
  <p>Text</p>
  <div class="menu">
    <ul>
      <li>Menu 1</li>
      <li>Menu 2</li>
      <li>Menu 3</li>
    </ul>
  </div>
</div>

CSS

.container {
  width: 30px;
  height: 20px;
  background-color: red;
}

ul {
  list-style-type: none;
  padding: 0;
}

.menu { 
  height: 0;
  visibility: hidden;
  top: -50px;
  position: absolute;
  transition: all .5s ease;
}

.container:hover .menu {
  visibility: visible;
  top: 20px;
}

.container .menu ul li {
  border: 1px solid black;
  width: 50px;
}

Thanks in advance!

1
  • give the ul a position and a z-index of less than the menu Commented Jul 27, 2016 at 19:54

2 Answers 2

1

Try Z Index. Give z-index:1 to menu and z-index:-1 to ul

[Link][1]


  [1]: https://jsfiddle.net/Le8jv91j/
Sign up to request clarification or add additional context in comments.

Comments

1

As already mentioned, use a z-index of -1. Codepen

.menu { 
    height: 0;
    visibility: hidden;
    top: -50px;
    position: absolute;
    transition: all .5s ease;
    z-index: -1;
}

Comments

Your Answer

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