javascript - Tray Menu Slides Down After Content -


i've been looking @ menu, having weird issue can't seem figure out--and feeling kind of stupid over! want slide down tray menu on existing content. however, slides down underneath content. can't seem figure out why happening. help?

https://jsfiddle.net/ticklishoctopus/gdfv4wzn/

$(window).on('resize', function() {        $('ul.sub-menu').each(function() {          var width = 0;          $(this).children('li').each(function() {            width += $(this).width();            console.log('inner width' + $(this).width());          });          console.log('total width' + width);          $(this).css('padding-left', $(window).width() / 2 - width / 2);        });      });      $(window).trigger('resize');
@import url(https://fonts.googleapis.com/css?family=cabin);      html,      body {        margin: 0;        padding: 0;        font-family: cabin, sans-serif;        text-transform: uppercase;        background-color: #ade;      }        .clear {        clear: both;      }        ul,      li {        list-style: none;        text-indent: none;      }        .menu {        width: 100%;        z-index: 50;        display: block;        background: blue;        height: 110px;        margin-top: 0px;        box-sizing: border-box;        background-image: url('images/gradient-line.png');        background-repeat: repeat-x;        background-position: left bottom;        padding-right: 30px;      }        .menu .menu-item {}        .menu .menu-item {        display: block;        float: left;        font-size: 13pt;        line-height: 64px;        height: 100px;        font-weight: 700;        text-decoration: none;        color: #fff;        padding: 5px 30px;        margin-top: 25px;      }        .menu .menu-item .sub-menu {        position: absolute;        left: 0;        top: -50px;        z-index: -1;        transition: .5s;        width: 100%;      }        .menu .menu-item .sub-menu li {        display: inline-block;      }        .menu .menu-item:hover .sub-menu {        top: 150px;      }        .menu .menu-item .sub-menu .menu-item {        text-align: center;        background: rgba(155, 75, 105, .8);        padding: 0 20px;        display: block;        float: left;        color: #ddd;        border: none;        height: 64px;        font-size: 12px;      }        .menu .menu-item .sub-menu .menu-item a:hover {        color: #fff;      }        .menu .menu-item:hover .sub-menu .menu-item {        height: 64px;        display: block;        opacity: 1;        filter: alpha(opacity=100);        -webkit-transition: 0.5s ease;        -moz-transition: 0.5s ease;        -ms-transition: 0.5s ease;        -o-transition: 0.5s ease;        transition: 0.5s ease;      }        .sub-menu {        background-color: #fff;        padding-top: 30px;        padding-bottom: 20px;        text-align: center;      }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <body>          <header>            <ul class="menu">            <li class="menu-item"><a href="#">menu 1 <i class="fa fa-sort-desc"></i></a>              <ul class="sub-menu">                <li class="menu-item"><a href="#">mission</a></li>                <li class="menu-item"><a href="#">history</a></li>                <li class="menu-item"><a href="#">news &amp; conventions</a></li>                <li class="menu-item"><a href="#">customer service</a></li>              </ul>            </li>              <li class="menu-item"><a href="#">menu 2 <i class="fa fa-sort-desc"></i></a>              <ul class="sub-menu">                <li class="menu-item"><a href="#">catalog</a></li>                <li class="menu-item"><a href="#">sketches</a></li>                <li class="menu-item"><a href="#">accessories</a></li>              </ul>            </li>              <li class="menu-item"><a href="#">menu 3 <i class="fa fa-sort-desc"></i></a>              <ul class="sub-menu">                <li class="menu-item"><a href="#">catalog</a></li>                <li class="menu-item"><a href="#">sketches</a></li>                <li class="menu-item"><a href="#">accessories</a></li>              </ul>            </li>            </ul>          </header>          <p class="clear"></p>          <main>            content goes here.          </main>        </body>

as noted, have have positioned elements way down sub-menu. helps wrap menu ul in positioned div higher z-index page content:

.header-wrapper {   position: relative;   display: block;   z-index: 1; } .menu {     position: relative;     width: 100%;     display:block;     background: blue;     height: 110px;     margin-top: 0px;     box-sizing: border-box;     background-image: url('images/gradient-line.png');     background-repeat: repeat-x;     background-position: left bottom;     padding-right: 30px; } .menu .menu-item {   position: relative; } .menu .menu-item {     display: block;     position: relative;     float: left;     font-size: 13pt;     line-height: 64px;     height: 100px;     font-weight:700;     text-decoration: none;     color: #fff;     padding: 5px 30px;     margin-top: 25px; } 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

android - Keyboard hides my half of edit-text and button below it even in scroll view -