css - Divs overlapping - push one up and the other down? -
i have "hamburger" mobile navigation button when clicked brings div titled #navigation. however, due div positioned (it in other divs) div not extend 100% of width of document, 100% of width of container div.
not problem there secondary issue because navigation div overlaps both header div , div below it. i'd rather push header , div below down.
whilst take div out of container , possibly fix problems placing elsewhere, causes problems navigation on full size version of page #navigation div same both versions of page, different styling. here's code.
body { margin: 0; line-height: 1.428; } .wrap { width: 90%; max-width: 71.5em; margin: 0 auto; padding: 0.625em 0.625em; } #header { background: #442869; padding-top: 1em; padding-bottom: 1em; min-height: 6em; } #mobile-navigation-btn { display: none; float: right; } #navigation { display: block; float: right; } #navigation ul { list-style: none; } #navigation li { display: inline-block; float: left; padding-right: 2em; padding-top: 0.7em; padding-bottom: 0.7em; } #navigation li:last-child { padding-right: 0em; } #navigation li { color: #ffffff; text-decoration: none; } .show-menu { text-decoration: none; color: black; background: #ac3333; text-align: center; padding: 20px 10px; border: 1px black solid; } .show-menu:hover { background: #ac1111; } #extra { background: #222922; padding-top: 1em; padding-bottom: 1em; min-height: 2em; color: white; } /*hide checkbox*/ input[type=checkbox]{ display: none; } /*show menu when invisible checkbox checked*/ input[type=checkbox]:checked ~ #navigation{ display: block; } #hamburger { display: inline-block; } .icon-bar { display: block; width: 22px; height: 2px; border-radius: 1px; margin-bottom: 4px; background-color: black; } @media screen , (max-width : 920px) { #mobile-navigation-btn { display: block; } #navigation { display: none; width: 100%; margin: 0; padding: 0; background-color:#333333; top: 0; left: 0; } /*create vertical spacing*/ #navigation li { margin-bottom: 1px; } /*make dropdown links vertical*/ #navigation ul li { display: block; float: none; margin:0; padding:0; } /*make menu links full width*/ #navigation ul li, li { width: 100%; } }
<!doctype html> <head> <script> // picture element html5 shiv document.createelement( "picture" ); </script> <script src="picturefill.min.js" async> </script> <title> </title> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <div id="header"> <div class="wrap"> <picture> <source srcset="seiri-logo-regular.png" media="(min-width: 1100px)"> <img srcset="seiri-logo-small.png" alt="…"> </picture> <div id="mobile-navigation-btn"> <label for="show-menu" class="show-menu"> <div id="hamburger"> <span class="icon-bar"> </span> <span class="icon-bar"> </span> <span class="icon-bar"> </span> </div> menu </label> </div> <input type="checkbox" id="show-menu" role="button"> <div id="navigation"> <ul> <li> <a href="#" class="current"> home </a> </li> <li> <a href="#"> customer research </a> </li> <li> <a href="#"> business improvement </a> </li> <li> <a href="#"> contact </a> </li> <li> <a href="#"> blog </a> </li> </ul> </div> </div> </div> <div id="extra"> <div class="wrap"> test </div> </div> </body> </html>
i posted , had advice perhaps adding "position: relative" #header , "position: absolute" #navigation (plus using "top" adjust location) solve problem, doesn't work either doesn't push divs below down account space navigation takes up!
any appreciated.
Comments
Post a Comment