html - Generate "table" with <div> -
i'd generate representation below <div>
. constraints :
- the full size = 100%
- the first + second column = 50%, 3rd + 4th column = 50%
- the first column smaller second, second take "the rest of place", same column 3 , 4 :)
- the 3rd lines, combines 2 cells
- the last line combine 4 cells
- don't worry color :)
ps : no debate table vs div ;-)
here proposed markup:
<div class="row"> <div class="col half"> <div class="col narrow">(1)</div> <div class="col remainder">(2)</div> </div> <div class="col remainder"> <div class="col narrow">(1)</div> <div class="col remainder">(2)</div> </div> </div> <div class="row"> <div class="col half">(3)</div> <div class="col remainder">(3)</div> </div> <div class="row"> (4) </div>
and styles:
/* structure */ .row { clear: both; overflow: hidden; } .col { float: left; } .half { width: 50%; } .narrow { width: 30%; } .remainder { float: none !important; overflow: hidden; } /* skin: demo */ .row { text-align: center; border-bottom: 1px solid #999; } .half { background: #fcc; } .narrow { background: #ccf; } .remainder { background: #cfc; }
the first 2 rows split half. in each half 2 cells: first called narrow
, floated. put 30% on width 1 demo (note: that's 30% of half of row). other column called remainder
, not floated. uses overflow set own rendering context, means fills block right of floated column.
you can have more floated columns (left or right), 1 remainder.
i put on jsfiddle: play it.
Comments
Post a Comment