javascript - Div is moving when I hide an element and show another element -
i working on mobile version of nav bar have hamburger menu , when click on it pulls out menu. hamburger icon hidden javascript , css , javascript shows 'x' icon user can close menu , go webpage. when 'x' icon shows moves title little left , down. i've checked margins , padding , borders , empty space above title. can make title doesn't move? empty picture 'x' icon.
var main = function() { /* push nav on 285px on */ $('.hamburger').click(function() { $('#menu').animate({ left: "0px" }, 200); $('.hamburger').hide(); $('.close').show(); }); /* push them */ $('.close').click(function() { $('#menu').animate({ left: "-100%" }, 200); $('.hamburger').show(); $('.close').hide(); }); }; $(document).ready(main); @font-face { font-family: call_of_ops_duty; src: url('../fonts/call_of_ops_duty.otf'); } body { margin:0; } .header { background-color:#0d47a1; width:100%; height:56px; line-height:56px; display:block; position:absolute; } .hamburger { position: relative; display: inline-block; width: 1.25em; height: 0.8em; margin-right: 0.3em; border-top: 0.2em solid #fff; border-bottom: 0.2em solid #fff; z-index:8; } .hamburger:before { content: ""; position: absolute; top: 0.3em; left: 0px; width: 100%; border-top: 0.2em solid #fff; } .close { display:inline-block; position: relative; left:5%; top:7%; height:40px; width:40px; display:none; } /*.close img { position:relative; width:40px; height:40px; display:none; }*/ #heading { position:relative; display:inline-block; left:15%; top:0; font-family: call_of_ops_duty; color:white; font-size:18px; } #heading font { font-size:14px; } span { padding-left:2%; left:7%; } #menu { position:fixed; top:56px; left:-100%; width:100%; height:100%; z-index:10; background-color:gray; } #menu ul { top:25%; list-style:none; padding-left:0; } #menu { text-decoration:none; color:black; } #menu li { font-family: call_of_ops_duty; font-size:24px; text-align:center; } #menu li:first-child { top:56px; } <!doctype html public "-//w3c//dtd xhtml 1.0 strict//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0" charset="utf-8"> <link type="text/css" rel="stylesheet" href="css/header.css"/> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css"> <script src="js/header.js"></script> <body> <div class="header"> <span class="hamburger"></span> <img class="close" src="img/x.png"> <div id="heading"> title </div> <div id="menu"> <ul> <li><a href="cellhome.php">home</a></li> <li><a href="cellwhyroot.php">root</a> <ul> <li><a href="cellbestrootapps.php">root apps</a></li> </ul> </li> <li><a href="jailbreak.php">jailbreak</a> <ul> <li><a href="jailbreakapp.php">jailbreak apps</a></li> </ul> </li> <li><a href="contact.php">contact me</a></li> <!--<li><a href="celllogin.php">appointment</a></li>--> </ul> </div> </div> </body> </html>
changing heading inherit seems work.
#heading { position: inherit; }
Comments
Post a Comment