javascript - sidebar disappear when window is at a certain width -


i have created site side bar. sidebar has been made change size window shrinks there still isn't enough space on page. have been looking around find way can have side bar disappear when screen shrunk. there needs button can press bring sidebar until mouse isn't on sidebar more. thought mobile devices to. have been looking while can't seem right. code below body :)

body {      margin: 0;      background: -webkit-linear-gradient(left,  lightblue,#ffff66, #ff3333 ); /* safari 5.1 6.0 */  }    ul {      list-style-type: none;      margin: 0;      padding: 0;      width: 25%;        position: fixed;      height: 100%;      overflow: auto;        }    li {      display: block;      color: #000;      padding: 8px 0 8px 16px;      text-decoration: none;  }    li a.active {      background-color: #4caf50;      color: white;  }    li a:hover:not(.active) {      background-color: #555;      color: white;  }
<ul>    <li><a class="active" href="index.php">home</a></li>    <li><a href="messages/message.php">messages</a></li>    <li><a href="ask.php">ask</a></li>    <li><a href="cloud.php">cloud access</a></li>     <li><a href="gallery.php">gallery</a></li>    <ul style="float:right;list-style-type:none;">      <li><a href="#about">about</a></li>      <li><a href="login.php">login</a></li>          </ul>  </ul>

at moment resizes need disappear @ width reappear , when under width can't see there needs button make appear @ width preferably width code says do. if can't understand message hope can complete :)

you have write media query specific size on want hide sidebar put id="tooglebutton" on button

#tooglebutton {display:none} //first hide button on other sizes  @media screen , (max-width: 768px) { ul{display:none;} #tooglebutton {display:block} // show button on 768 size } 

in case sidebar hide on 768px width

and can toggle (hide or show) sidebar

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script> <script> $(document).ready(function(){     $("#tooglebutton").click(function(){         $("ul").toggle();     }); }); </script> 

Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -