CSS drop down navigation

后端 未结 1 1644
后悔当初
后悔当初 2021-01-23 08:09

I\'m sure this is something simple I\'m missing... My drop down menu is opening within the main navigation, widening it. Here is a link to the page I\'m working on. The issue

1条回答
  •  情歌与酒
    2021-01-23 08:17

    You have to add a position:absolute to the selector .navigation li ul

    .navigation{
    margin-right: auto;
    margin-left: auto;
    width: 100%;
    background-color: #0f9cde;
    position: absolute;
    display: block;
    margin-bottom: 15px;
    z-index: 1000;
    margin-left: -15px;
    }
    /*Strip the ul of padding and list styling*/
    .navigation ul{
    list-style-type: none;
    margin: 0 auto;
    padding: 0;
    position: relative;
    z-index: 10000;
    text-align:center;
    }
    
    /*Create a horizontal list with spacing*/
    .navigation li{
    display:inline-block;
    margin-right: 0px;
    background-color:#0f9bde;
    
    }
    
    /*Style for menu links*/
    .navigation li a {
    
    min-width: 189px;
    height: 50px;
    text-align: center;
    line-height: 50px;
    font-family: 'Maven Pro', sans-serif;
    font-size:18px;
    color: #fff;
    width:100%;
    background-color: #0f9cde;
    text-decoration: none;
    display:block;
    
    }
    
    /*Hover state for top level links*/
    .navigation li:hover a {
    color: #f7a800;
    text-decoration: underline;
    }
    
    /*Style for dropdown links*/
    .navigation li:hover ul a {
    background: #f7a800;
    color: #ffffff;
    height: 40px;  
    line-height: 40px;
    z-index: 10001;
    }
    
    /*Hover state for dropdown links*/
    .navigation li:hover ul a:hover {
    background: #fff;
    color: #f7a800;
    }
    
    /*Hide dropdown links until they are needed*/
    .navigation li ul{
    display: none;
    z-index: 10001;
      
      position: absolute;
    }
    
    /*Make dropdown links vertical*/
    .navigation li ul li {
    display: block;
    float: none;
    }
    
    /*Prevent text wrapping*/
    .navigation li ul li a {
    width: auto;
    min-width: 100px;
    padding: 0 20px;
    }
    
    .navigation ul li:hover ul{
    display:block;
    }
    
    /*Display the dropdown on hover*/
    navigation ul li a:hover  {
    display: block;
    
    }

    0 讨论(0)
提交回复
热议问题