Answer the question
In order to leave comments, you need to log in
How to make div width dependent on content?
Tried float: left, but in this case it only works in IE and Opera.
As is
As we would like - works in IE and Opera with float: left
When placing images, if it does not fit, it is transferred to the next line, while in the place where the image did not fit, a void is formed, the block remains stretched to full width.
Answer the question
In order to leave comments, you need to log in
As already mentioned above, a good wrapping of block elements to a new line can be achieved by using an inline block. I recommend for this purpose to use the following inline block code, fully tested by many months of using it in one of the main
/* {{Строчный блок}}
* http://habrahabr.ru/blogs/css/96152/
* ↑ http://www.smashingmagazine.com/2010/06/10/50-new-useful-css-techniques-tools-and-tutorials/
* ↑ http://blog.mozilla.com/webdev/2009/02/20/cross-browser-inline-block/
* ↑ первоисточник
*/
.lineBlock {
border: 0; margin: 0.3em 0.15em; padding: 0;
display: -moz-inline-stack; /* ← Firefox 2 backwards compatibility */
display: inline-block;
vertical-align: top;
/* ↓ IE6 & IE7 «hasLayout» voodoo */
zoom: 1;
*display: inline;
/* ↑ IE6 & IE7 starhack ← http://www.ejeliot.com/blog/63 */
}
www.artlebedev.ru/tools/technogrette/html/thumbnails-center/ Seems like
it, but yours is even easier.
float:left; overflow:hidden;
and for bottom blocks clear:left;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question