Last active
December 26, 2018 23:02
-
-
Save perymimon/7857624 to your computer and use it in GitHub Desktop.
open sidebar menu with :target
From http://css-tricks.com/off-canvas-menu-with-css-target/
run:"http://plnkr.co/edit/gist:7857624?p=preview"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link href="style.css" rel="stylesheet" /> | |
<!-- I am collapsed by default --> | |
<nav id="main-navigation" class="navigation"> | |
<a href="#">Nav Links</a> | |
<!-- more --> | |
</nav> | |
<!-- I am full width by default --> | |
<div class="page-wrap"> | |
<header> | |
<a href="#main-navigation">Menu</a> | |
<a href="#scrolldown">scroll down</a> | |
<h1>Title</h1> | |
</header> | |
<!-- content --> | |
</div> | |
<div class="bottom" id="scrolldown">bottom</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.bottom { | |
position:relative; | |
top:1000px; | |
background-color:rgb(10,100,140); | |
} | |
.navigation { | |
/* Collapsed */ | |
overflow: hidden; | |
position: fixed; | |
width: 0; | |
top: 0; | |
left: 0; | |
height: 100%; | |
background-color:red; | |
} | |
.page-wrap { | |
width: 100%; | |
float: right; | |
} | |
.navigation { | |
transition: width 0.3s ease; | |
} | |
#main-navigation:target { | |
width: 20%; | |
} | |
#main-navigation:target + .page-wrap { | |
width: 80%; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment