开发者

CSS - Div must fit content AND break line

开发者 https://www.devze.com 2023-02-13 09:49 出处:网络
Is there a way to make a div element fit its content AND break 开发者_如何学Cthe line, so that the next element is under that div?

Is there a way to make a div element fit its content AND break 开发者_如何学Cthe line, so that the next element is under that div?

I´ve tried to set the display property to inline-block, but then the div doesn´t break the line anymore... By default, it breaks the line, but doesn´t fit its content.

Hope someone can help me.

Thanks!


If you're trying to do it without an extra div, I don't think there's a way. Here's how with 2 divs:

<div>
  <div style="background-color: #FF0000; display: inline">Test</div>
</div>


Something like this buddy?

http://jsfiddle.net/A6n2h/2/

I used this CSS code:

.container div *{float:left; display:inline-block; clear:both;}

There was a few errors in your HTML code too.

0

精彩评论

暂无评论...
验证码 换一张
取 消