html - Position:fixed menu disappears when using bottom:0 -
testing on chrome: want menu stick bottom left. shows when not using bottom: 0. if use top works. causing issue? 
.mobile-menu {    display: block;    position: fixed;    left: 0;    bottom: 0;    margin: 0;    padding: 30px;    width: 80px;    z-index: 999;    background-color: red;  }<div class="wrapper">    <nav class="mobile-menu">testing menu</nav>    <header class="header">      <div class="main-logo">        <object data="svg/main-logo.svg" type="image/svg+xml">          <img src="fallback.jpg" />        </object>      </div>      <nav class="main-nav">        <ul>          <li><a href="">about</a>          </li>          <li><a href="">services</a>          </li>          <li><a href="">contact</a>          </li>        </ul>      </nav>    </header>  </div>
make .wrapper position: relative , .mobile-menu position: absolute. in order illustrate problem better, added content under header. green menu = good , red menu = bad.
solution
- in demo have renamed red menu to: .mobile-menuoriginal
- i have added identical .mobile-menu, changedbackground-color: green,position: absolute
reasons
- position: fixedplace element relative viewport,- bottom:0place element @ bottom of screen.
- position: relativeplaces element in relation it's original position, placing- .wrapperin- position: relativeno specific coordinates (i.e.- top,- right,- left, ,- bottom),- .wrapperstays is. reason why- .wrapperneeds can out of normal flow.
- position: absoluteplaces element in relation it's parent, putting- .mobile-menu- absolutepositioning, position within borders of- .wrapperbecause- .wrapper- .mobile-menu's parent , closest positioned element. mentioned closest positioned because there exceptions said positioned parents. please refer article before confuse you.
edit
@t.niese further explains:
[...]the reason why .wrapper needs can out of normal flow.[...] out of flow bit misleading, because element position relative has visual displacement object, still use same space in flow before , still influenced surrounding in contrast absolute move element out of flow.
.wrapper {    position: relative;  }  .mobile-menu {    display: block;    position: absolute;    left: 0;    bottom: 0;    margin: 0;    padding: 30px;    width: 80px;    z-index: 999;    background-color: green;  }  .mobile-menuoriginal {    display: block;    position: fixed;    left: 0;    bottom: 0;    margin: 0;    padding: 30px;    width: 80px;    z-index: 999;    background-color: red;  }<!doctype html>  <html>    <head>  </head>    <body>    <div class="wrapper">      <nav class="mobile-menu">testing menu</nav>      <nav class="mobile-menuoriginal">testing menu</nav>      <header class="header">        <div class="main-logo">          <object data="svg/main-logo.svg" type="image/svg+xml">            <img src="fallback.jpg" />          </object>        </div>        <nav class="main-nav">          <ul>            <li><a href="">about</a>            </li>            <li><a href="">services</a>            </li>            <li><a href="">contact</a>            </li>          </ul>        </nav>      </header>    </div>        <section>      <h1>title</h1>      <h2>byline</h2>      <p>content</p>      <p>content</p>      <p>content</p>      <p>content</p>      <p>content</p>      <p>content</p>      <p>content</p>      <p>content</p>      <p>content</p>      <p>content</p>      <p>content</p>      <p>content</p>      <p>content</p>      <p>content</p>      <p>content</p>      <p>content</p>      <p>content</p>      <p>content</p>      <p>content</p>      <p>content</p>      <p>content</p>      <p>content</p>      <p>content</p>      <p>content</p>      <p>content</p>      <p>content</p>      <p>content</p>      <p>content</p>      <p>content</p>      <p>content</p>      <p>content</p>      <p>content</p>      <p>content</p>      <p>content</p>      <p>content</p>    </section>    <footer>      <h3>footer</h3>    </footer>  </body>    </html>
Comments
Post a Comment