How to make div width depended on content?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
10 views
Tried float: left, but in this case it only works in IE and Opera.

As is
image

As we would like — works in IE and Opera with float: left
image

When placing the image if it doesn't fit, it wraps to the next line in the place where the image is not fit to form a void, the block remains stretched over the entire width.
by | 10 views

7 Answers

0 like 0 dislike
As mentioned above, a good transfer of block elements on a new line can be achieved by use of the lower case unit. I recommend for this purpose use the following code string block, full tested months of use, it is one of the main CSS files in the "Tradition", the Russian encyclopedia:
\r
/* {{Line block}} * 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/ * ^ the original */ .lineBlock { border: 0; margin: 0.3 em 0.15 em; padding: 0; display: -moz-inline-stack; /* ← Firefox 2 backwards compatibility */ display: inline-block; vertical-align: top; /* ↓ IE6 & IE7 "hasLayout" . */ zoom: 1; *display: inline; /* ↑ IE6 & IE7 starhack ← http://www.ejeliot.com/blog/63 */ }

As you can see, this code is structured on the principles of backward compatibility with Firefox 2 and IE 6 and 7.
\r
If the frame of the outdoor unit will not be absolutely against the limits of the internal inline, then by all means try and power also to execute as a string block, and that is to give them the class "lineBlock" described the above CSS code.
by
0 like 0 dislike
try diva instead of a span with the property display:inline-block;
by
0 like 0 dislike
display: inline-block;
\r
just that ;)
by
0 like 0 dislike
Javascript?
by
0 like 0 dislike
by
0 like 0 dislike
And height tried to ask?
by
0 like 0 dislike
Damn, and I have a similar problem =(
by

Related questions

0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
0 like 0 dislike
4 answers
110,608 questions
257,186 answers
0 comments
28,140 users