html - How To Make A Responsive Sidemenu In CSS -
i've finished coding website 1024x768 resolution , want add @media queries code sidebar disappears when screen @ width of 980px , stays way down there. have tried adding @media max-width 980 myself not seem working @ all. i've tried in various places on page again, no luck. it's frustrating! code below (sorry if it's long, i'm gonna leave in there avoid questions regarding code).
html:
<head lang="en"> <meta charset="utf-8"> <meta name="viewport" content="width=device-width" /> <title>lakeside books</title> <link rel="stylesheet" type="text/css" href="masterstyle.css"> <meta name="viewsize" content="width-device-width,initial-scale=1.0"> <!--[if ie]> <script type="text/javascript" src="_http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> </head> <body> <div id="wrapper"> <div id="sidebar"> <nav id="nav"> <h3 id="welcometext">welcome to<br>lakeside books</h3> <div id="searchbar"> <form action="http://www.example.com/search.php"> <input type="text" name="search" placeholder=" ...search book title" class="searchstyle"/> </form> </div> <ul> <li style="background-color: #333"> <a href="1index.html" class="link"> <span style="color: #ed786a">home</span> </a> </li> <li> <a href="2catgeories.html" class="link"> categories </a> </li> <li> <a href="http://example.com" class="link"> bestsellers </a> </li> <li> <a href="http://example.com" class="link"> find </a> </li> <li> <a href="http://example.com" class="link"> contact </a> </li> </ul> </nav> </div>
css:
html, body { /* ### */ margin:0; padding:0; height:100%; width:100%; } body { background-color: #fdfdfd; font-family: arial, "open sans", sans-serif-light, sans-serif, "segoe ui"; } #wrapper { width: 100%; height: 100%; margin:0 0 0 20%; /* ### */ } #sidebar { background-color: #212528; position: fixed; width: 20%; height: 100%; top: 0; left: 0; overflow: hidden; text-shadow: 0.1em 0.1em 0 rgba(0, 0, 0, 0.1); } #nav { color: #dadada; display: block; max-width: 100%; } #nav ul { padding-left: 0; } #nav li { list-style-type: none; margin: 0; padding: 0.75em 0 0.75em 0; text-align: center; max-width: 100%; } #nav li:hover { background:#333; } #nav li { display: block; padding: 0.5em 0; } .link { text-align: right; margin-right: 25%; letter-spacing: 1px; display: block; } #nav li a:link{ color: #dadada; text-decoration: none; } #nav li a:visited{ color: #dadada; text-decoration: none; } #nav li a:hover{ color: #dadada; text-decoration: none; } #nav li a:active{ color: #dadada; text-decoration: none; } #welcometext { text-align: center; /*font-style: italic;*/ text-transform: uppercase; font-size: 1em; margin-top: 2em; } #searchbar { width: 70%; margin-left: auto; margin-right: auto; padding: 1em 1em 0.5em 1em; text-align: right; } #searchbar .searchstyle{ -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; } #searchbar input { max-width: 95%; } /*-------media styles-------*/ @media , (max-width: 980px){ #sidebar{ float: none; } }
Comments
Post a Comment