html - equally dividing columns doesnt work without commenting out returns, is there a better way? -
i tried around bit because didnt understand causes blank spaces between equally divided columns, http://jsfiddle.net/esvne/ helped me took while until noticed comments,
<div id="wrapper"> <div id="c1" style="background:red"></div><!-- --><div id="c2" style="background:blue"></div><!-- --><div id="c3" style="background:yellow"></div> </div>
and me 1 line solution, ugly!
is there better way this?
(that is, dividing div equal parts without padding/margin hacks or one-line/comment stuff)
it's inline-block
that's creating white-space between divs: attribute's name suggests, works bit inline
, means take spaces , line-breaks "consideration", speak. (hope made sense.) try using display: block;
, float: left;
this:
div div { height: 50px; background-color: green; width: 32.666%; display: block; float: left; }
notice width bit less third - that's account margin between 3 blocks. add class 2 left divs:
<div id="wrapper"> <div id="c1" class="left" style="background: red;"></div> <div id="c2" class="left" style="background: blue;"></div> <div id="c3" style="background:yellow"></div> </div>
and last, more css add padding between divs:
div .left { margin-right: 1%; }
here's fiddle: http://jsfiddle.net/niffler/g2fbq/
Comments
Post a Comment