Skip to content Skip to sidebar Skip to footer

Css - Why Are My Nav Div And Middle Div Overlapping?

You may ignore the code that aren't the actual divs themselves as most of the code is just to make a dropdown nav, but my error may be in there. I'm trying to add a responsive whit

Solution 1:

To accomplish this:

  • Change the floated list items to inline blocks.
  • Change in children list items to display: block;
  • Remove position: absolute on the list items

body {  background: red;  }

div#Container
{
  position: relative;
}

.nav
{
  width: 100%;  
  position: absolute;
  background-color: white;  /*Code to add a white background to list*/padding: 15px;  
}
          /*Code up until line 64 to make a dropdown menu */.nava
  {
    color: #ffffff;
    text-decoration: none;
    background-color: #000000;
  }

  .navul
  {
    display:block;
  }

  .navula
  {
    display: block;
    float:left;
    width: 150px;
    padding: 10px20px;
    border: 1px solid #ffffff;
    text-align: center;
    font-size: 1.3em;
  }

  .navula:hover
  {
    background: red;
  }

  .navulli
  {
    /*display: block;
    float:left;
    position: relative*//* Add this */display: inline-block;
    vertical-align: top;
  }
  
  /* Add this */.navululli {  display: block;  }

  .navulli:hover > ul
  {
    display:block;
  }

  .navulliul
  {
    margin:0;
    padding: 0;
    display: none;
    /*position: absolute;*/background-color: #000000;
    top: 45px;
  }
  
 div#middle
{
  position: absolute;
}
<divid="Container"><divclass="nav"><ul><li><ahref="#">Home</a></li><li><ahref="#">Cars</a></li><li><ahref="#">Parts &amp; Tools</a><ul><li><ahref="#">Parts</a></li><li><ahref="#">Tools</a></li></ul></li><li><ahref="#">About</a></li><li><ahref="#">Contact</a></li></ul></div></div>

Solution 2:

div#middle 
  {
    position: absolute;
  }

Please also post where is the middle div in html code, it may help us figure out the structure of page.

Post a Comment for "Css - Why Are My Nav Div And Middle Div Overlapping?"