make css dropdown menu responsive -
i'm trying make css drop-down menu responsive according browser window.
i want menu text stay centered according browser window
please see video examples of intended behavior:
https://youtu.be/zpwforrw_cc?t=34m23s
/* ------------------------------------------ */ /* basic setup */ /* ------------------------------------------ */ * { margin: 0; padding: 0; box-sizing: border-box; } .page-wrap { width: 1216px; margin: 0 auto; } /* ------------------------------------------ */ /* page content */ /* ------------------------------------------ */ .box1 { height: 30px; width: 300px; background: #8242b1; } .box2 { height: 30px; width: 300px; background: #b14242; } .box3 { height: 30px; width: 300px; background: #424bb1; } .page-content { display:flex; justify-content: center; transition: ease-in-out 0.3s; position:relative; top: -260px; z-index: 0; } .toggle { transition: ease-in-out 0.3s; text-decoration: none; font-size: 30px; color: #eaeaea; position:relative; top: -120px; left: 20px; z-index: 1; } .toggle:hover { color:#cccccc; } .sidebar { display:flex; justify-content: center; align-items: center; transition: ease-in-out 0.3s; position: relative; top: -220px; bottom: 0px; left: 0px; height: 220px; width: auto; padding: 30px; background: #333; z-index: 1; } .sidebar li { display:flex; justify-content: center; list-style: none; color: rgba(255, 255, 255,0.8); font-family: 'lato', sans-serif; font-size: 16px; margin-bottom: 16px; cursor: pointer; } .sidebar li:hover { color: rgba(255, 255, 255,1); } #sidebartoggler { display: none; } #sidebartoggler:checked + .page-wrap .sidebar { top: 0px; } #sidebartoggler:checked + .page-wrap .toggle { top: 100px; } #sidebartoggler:checked + .page-wrap .page-content { padding-top: 220px; }
<!doctype html> <html lang="en"> <head> <link rel="stylesheet" type="text/css" href="resources/css/style.css"> <link href='https://fonts.googleapis.com/css?family=lato:400,900' rel='stylesheet' type='text/css'> </head> <body> <input type="checkbox" id="sidebartoggler" name="" value=""> <div class="page-wrap"> <div class="sidebar"> <ul> <li>home</li> <li>projects</li> <li>clients</li> <li>blog</li> <li>contact</li> </ul> </div> <label for="sidebartoggler" class="toggle">☰</label> <div class="page-content"> <div class="box1"></div> <div class="box2"></div> <div class="box3"></div> </div> </div> </body> </html>
this work,
.page-wrap{ width:1216px; }
+ use media queries follows:
@media screen , (max-width: 1216px) { .page-wrap{ width: 100%;} }
Comments
Post a Comment