html - CSS responsive nested grid height -
html - CSS responsive nested grid height -
i teaching myself how setup responsive grid layout automatic adjust on device size. far good, having issue the height of of boxes not adjusting. see here code http://jsfiddle.net/shuka/tbe32q3h/
html
<body> <div id="section2"> <div class="container grid2"> <article class="col half">map</article> <article class="col half" style="background-color:#069;"> <div class="grid2"> <article class="col quater">box 1</article> <article class="col quater">box 2</article> </div> <div class="grid2"> <article class="col quater">box 3</article> <article class="col quater">box 4</article> </div> </article> <br/> </div>
css
body { margin: 0; padding: 0; } #section1 br,#section2 br,#section3 br, #topbar br { clear: both; } .container { margin: auto; max-width: 1400px; overflow:hidden; } .col { background: #eee; float: left; margin-left: 1.4%; margin-bottom: 20px; } .grid2 .col { width: 49.3%; } .grid2 .half { /*width: 48.4%;*/ height:49.3vw; /*max-width:678px;*/ max-height:690px; /*float:left;*/ position:relative; } .grid2 .quater { margin-left: 2.1%; margin-bottom: 2.1%; width: 48.95%; height:48.95vw; /*max-width:317px;*/ max-height:338px; /* float:left;*/ position:relative; } .grid4 .col:nth-of-type(4n+1), .grid3 .col:nth-of-type(3n+1), .grid2 .col:nth-of-type(2n+1) { margin-left: 0; clear: left; }
as can see when resize big boxes change, issue 4 smaller boxes, width changes height remain same. 4 boxes maintain square little when screen resized, if can spot have missed appreciated.
cheers shuka
this tricky layout pull off, did little playing around , think have work you:
http://jsfiddle.net/caseyrule/h0drc99g/
i decided treat max-width scenario hard-coded numbers, this:
@media (min-width: 900px) { /* max-width of container */ .half { height: 450px; /* max-width * 50% */ } .half.col1 { width: 432px; /* max-width * 48% */ } .half.col2 { width: 450px; /* max-width * 50% */ } .quarter { width: 216px; /* max-width * 24% */ height: 216px; /* max-width * 24% */ } .half.col1, .quarter.col1 { margin-right: 18px; /* max-width * 2% */ } .row1 .quarter { margin-bottom: 18px; /* max-width * 2% */ } }
i did max-width of 900px, see how works more within jsfiddle screen, easy alter 1400px had originally. alter max-width of container, , calculate numbers within media query indicated in comments. alternatively, automate of these calculations pre-processor less, encourage.
html css css3 responsive-design
Comments
Post a Comment