html - Adaptive width layout just with css3? -
i having lot of trouble figuring 1 out, have 3 columns: navbar (dark gray), main content (dark red) , sidebar (dark green) navbar can expanded , shrinked , sidebar can slide out , slide in (so change width 0 , 0). , want keep of responsive. idea shrink main content accordingly when or both navbar , sidebar expanded. unfortunately way can think change width of main content width: calc(100% - navbar width - sidebar width)
verbose when need check if sidbar expanded or navbar, or both not expanded etc...
here image illustrating how main content shrinks:
i assume flexbox used here somehow, not able figure out.
let example marku be
<nav> </nav> <main> </main> <aside> </aside>
note: nav , aside need 100% height of page , fixed in place.
you can use flex-box
this. simple approach follows: http://codepen.io/anon/pen/pgvvjb
you can change classes see how changes layout. note: using classes change width of columns use javascript or static css similarly.
code dump:
<div class="container"> <div class="small">nav</div> <div>content</div> <div class="medium">sidebar</div> </div> html, body, div { height: 100%; margin: 0; padding: 0; } .container { display: flex; } .container div { flex: 1; border: 1px solid #ccc; background: gray; } .small { max-width: 50px; } .medium { max-width: 150px; }
Comments
Post a Comment