css - 奇怪的 CSS 问题?使用 float 属性定位 div 元素

标签 css html positioning css-float

在 Dreamweaver 中,当我输入此 html 时:

<div style="float:left;width:100px;height:20px">a</div>
<div style="float:left;clear:left;width:100px;height:100px">b</div>
<div style="float:left;width:80px;height:100px">c</div>

div c 似乎与 div a 顶部的顶部对齐。这就是我想要的 显示,但是当在浏览器(firefox,即测试)中呈现时,div c 低于 div a 并改为与 div b 对齐。我该如何解决这个问题?

最佳答案

这似乎是 Dreamweaver 中的错误。

在同一上下文中,元素不会漂浮超过清除元素。

这听起来像你想要的:

<div style="width: 100px; float: left;">
    <div style="height:20px">a</div>
    <div style="height:100px">b</div>
</div>
<div style="float: left;width:80px;height:100px">c</div>

关于css - 奇怪的 CSS 问题?使用 float 属性定位 div 元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4827018/

相关文章:

html - wordpress 列中的 css 定位问题

css - rails 4 应用程序中有太多 css 文件的性能问题?

javascript - 在 chrome 中,div 没有排在前面的 div 问题之前

jquery - 如何打开垂直下拉菜单项以左对齐

html - CSS 元素不断换行

html - 单选按钮在 IE(和一些 FF)中看起来像复选框

html - 将一项从 float 定位更改为固定定位,CSS

css - 我如何在 Twitter Bootstrap css 框架中正确定位绝对 div

css - jQuery 手机 : position of paginational buttons

html - Div 100% 最小高度问题