如何只清除一个浮动对象?

发布于 2024-12-15 05:55:44 字数 196 浏览 2 评论 0原文

关于浮动和清算的问题。 这是小提琴。 如何让文本出现在红色对象下方? 如果我使用 clear: left,文本将出现在黑色对象下方,因为它的高度比红色对象高。 仅使用 float 和clear 是否有可能获得我正在寻找的外观?

A question about floats and clearing. Here's the fiddle.
How do I get the text to appear under the red object?
If I use clear: left, the text appears under the black object because it has greater height than the red one.
Is it possible to get that look I'm looking for by using only float and clear?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

回首观望 2024-12-22 05:55:44

您需要将 red div 后跟 h2 标签放入左侧浮动的包含 div 中(您可以从 red 中删除 float:left div,您可以从 h2 中删除 clear:left :)

http://jsfiddle.net/XqLFX/

You need to put red div followed by the h2 tag in a containing div that floats left (you can remove the float:left from the red div. and you can remove the clear:left from h2 :)

http://jsfiddle.net/XqLFX/

末蓝 2024-12-22 05:55:44

我认为你的设计是错误的。这是新的 jsfiddle

<div id="blue">
    <div id="black"></div>
    <div id="new">      
        <div id="red"></div>
         <h2>TEXT</h2>
    </div>
</div>

使新的 div 向左浮动

#new{width:200px;float:left}

I think you are wrong on wrong design. This is the new jsfiddle

<div id="blue">
    <div id="black"></div>
    <div id="new">      
        <div id="red"></div>
         <h2>TEXT</h2>
    </div>
</div>

Make the new div float left

#new{width:200px;float:left}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文