Created
August 11, 2020 15:25
-
-
Save michaschwab/27a9273e0590d58c92222a7787e04052 to your computer and use it in GitHub Desktop.
Responsive Column Layout with Collapsible Menu
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
<style> | |
#frame { | |
border: 2px solid; | |
padding: 20px; | |
width: 880px; | |
height: 400px; | |
resize: both; | |
overflow: auto; | |
} | |
</style> | |
<iframe id="frame" src="./website.html"></iframe> |
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
#frame { | |
display: grid; | |
grid-template-columns: 1fr auto; | |
height: 100%; | |
position: relative; | |
} | |
.collapsible { | |
width: 250px; | |
} | |
.collapsible .show-collapsed { | |
display: none; | |
} | |
@media(max-width: 650px) { | |
.collapsible { | |
width: 50px; | |
} | |
.collapsible .hide-collapsed { | |
display: none; | |
} | |
.collapsible .show-collapsed { | |
display: inline; | |
} | |
} | |
.collapsible.expanded { | |
width: 100%; | |
position: absolute; | |
height: 100%; | |
} | |
.collapsible.expanded .hide-collapsed { | |
display: inline; | |
} | |
.collapsible.expanded .show-collapsed { | |
display: none; | |
} | |
.collapsible .show-expanded { | |
display: none; | |
} | |
.collapsible.expanded .hide-expanded { | |
display: none; | |
} | |
.collapsible.expanded .show-expanded { | |
display: inline; | |
} | |
#content-wrap { | |
display: flex; | |
flex-wrap: wrap; | |
} | |
.content { | |
flex: 1 1 300px; | |
} | |
#overview { | |
background: #faa; | |
} | |
#detail { | |
background: #afa; | |
} | |
#menu { | |
background: #aaf; | |
} | |
a { | |
text-decoration: underline; | |
cursor: pointer; | |
} |
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" /> | |
<div id="frame"> | |
<div id="content-wrap"> | |
<div id="overview" class="content"><h2>Overview</h2></div> | |
<div id="detail" class="content"><h2>Detail</h2></div> | |
</div> | |
<div class="collapsible" id="menu"> | |
<div class="show-collapsed"> | |
<a onclick="this.parentElement.parentElement.classList.add('expanded')">Open</a> | |
<br /> | |
</div> | |
<div class="show-expanded"> | |
<a onclick="this.parentElement.parentElement.classList.remove('expanded')">Close</a> | |
<br /> | |
</div> | |
<h2 class="hide-collapsed">Menu</h2> | |
<h2 class="show-collapsed">M</h2> | |
<p class="hide-collapsed">Some big menu content</p> | |
<p class="show-collapsed">Min menu</p> | |
</div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment