清除元素上的浮动会使其跳转到非浮动元素下方
这很难解释,所以让我给你一个链接:http://jsbin。 com/izinoy/6/edit#html,live。 您可以轻松地看到不需要的行为:框“六”跳转到左侧导航下方,因为我应用了clear: left。
但显然我不希望这种情况发生。我不知道为什么会发生这种情况,因为导航没有浮动,那么为什么它会跳到导航下方,我该如何“修复”这个问题?
编辑: 我的问题有问题。我不知道这是怎么发生的:-/,但在问题中我说导航不是浮动的,即使它是!这就是为什么浮动对我来说没有意义。我忽略了这个“微小”的细节。是的,现在很明显为什么“六”框会跳到导航下方。
This is hard to explain, so let me just give you a link: http://jsbin.com/izinoy/6/edit#html,live.
You can easily see the unwanted behaviour: the box "six" jumps below the left navigation, because I applied a clear: left.
But I don't want this to happen, obviously. I don't know why this happens, cause the navigation is not floated, so why does it jump below navigation and how can I "fix" this?
EDIT:
There's a problem with my question. I don't know how this happened :-/, but in the question I said that navigation is not floated, even though it is! That's why the float didn't make sense to me. I overlooked this "tiny" detail. Yes, it's now obvious why the box "six" jumps below the navigation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
.box
选择器定义float: left
。此属性使元素浮动。关于
clear:left
,让我引用 https://developer.mozilla。 org/en/CSS/clear:如果您想垂直对齐所有框,请删除
float: left
。如果您不希望div
元素向下移动,请删除clear:left
。The
.box
selector definesfloat: left
. This property causes the element to float.About
clear:left
, let me quote https://developer.mozilla.org/en/CSS/clear:Remove
float: left
if you want to align all boxes vertically. Removeclear:left
if you don't want thediv
elements to shift down.