CSS clearfix无法正常工作 [英] CSS clearfix not working

查看:70
本文介绍了CSS clearfix无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此( http://jsfiddle.net/77RRA/1/)正在运行,而不是( http://jsfiddle.net/77RRA/).

This (http://jsfiddle.net/77RRA/1/) is working, while this (http://jsfiddle.net/77RRA/) is not.

clearfix是否不应该替换行< div style ="clear:both;"></div> ?

Isn't clearfix supposed to substitute the line <div style="clear: both;"></div>?

推荐答案

不是clearfix应该替换行< div style ="clear:both;"></div>

是的.那里的clearfix可以避免非语义的空标记.但是,要使其正常工作,您需要将其放在父元素上.(示例)

Yes. The clearfix is there to avoid a non-semantic empty tag. However, for this to work you need to place it on the parent element. (Example)

但是,在您的情况下,它不能解决兄弟姐妹将忽略浮动元素的问题.这不是clearfix的目的,您只需在您的 #child 兄弟姐妹上添加 clear:right (或同时 both ),即可恢复正常的文档流.

In your case however, it does not address the problem that siblings will ignore the floated element. This is not the intend of clearfix, you simply add clear:right (or both as you will) on your #child sibling to restore the normal document flow.

您的固定示例

这篇关于CSS clearfix无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆