Div side by side without float

The usual method when not using floats is to use display: inline-block: http://www.jsfiddle.net/zygnz/1/ .container div { display: inline-block; } Do note its limitations though: There is a additional space after the first bloc – this is because the two blocks are now essentially inline elements, like a and em, so whitespace between the two counts. … Read more

CSS container div not getting height

Add the following property: .c{ … overflow: hidden; } This will force the container to respect the height of all elements within it, regardless of floating elements. http://jsfiddle.net/gtdfY/3/ UPDATE Recently, I was working on a project that required this trick, but needed to allow overflow to show, so instead, you can use a pseudo-element to … Read more

CSS Float Logic

Here’s the part of the linked answer that’s most relevant to your question: When you float a block element, you are telling the browser to position it next to the previous floated object, so long as the container is wide enough (otherwise it will drop below the previous object). As the author mentions this is … Read more

Is there a disadvantage of using `display:table-cell`on divs?

display: table-cell is perfectly fine to use, with just one downside.. It doesn’t work in IE7 (or IE6, but who cares?): http://caniuse.com/#search=css-table If you don’t need to support IE7, then feel free to use it. IE7 still has some usage, but you should check your Analytics, and then make a decision. To answer your specific … Read more

Stacking DIVs on top of each other?

Position the outer div however you want, then position the inner divs using absolute. They’ll all stack up. .inner { position: absolute; } <div class=”outer”> <div class=”inner”>1</div> <div class=”inner”>2</div> <div class=”inner”>3</div> <div class=”inner”>4</div> </div>