css清除所有css_CSS清除修复

css清除所有css

Clearing CSS floats is just as important to creating CSS structures as anything could be.  For years we would clear our floated elements by adding one element with the clear: both; style simple to perform the clear.  This practice was fine but it introduced elements into the page that we really didn't need if there was a better way.  Today there is, and it involves using CSS pseudo-elements on a parent element!

清除CSS浮动对创建CSS结构同样重要。 多年以来,我们会通过添加一个带有clear的元素来清除浮动元素: 风格简单,表现清晰。 这种做法很好,但是如果有更好的方法,它会将页面中不需要的元素引入了我们。 今天有了,它涉及到在父元素上使用CSS伪元素!

CSS (The CSS)

This excellent CSS clear fix uses :before and :after pseudo-elements of the container to perform the clear:

这个出色CSS清除修复程序使用容器的伪元素:before:after来执行清除操作:


/* Assuming this HTML structure:

	<div class="clear">
		<div class="floated"></div>
		<div class="floated"></div>
		<div class="floated"></div>
	</div>
*/

.clear:before,
.clear:after {
    content: " ";
    display: table;
}

.clear:after {
    clear: both;
}


This is the part of the tutorial where I explain what each property does toward the goal but honestly, you probably don't care.  What's important is that this CSS reliably clears floating child elements so that the next set of elements has a clear plain to begin from!

这是本教程的一部分,我在其中解释每个属性对实现目标的作用,但说实话,您可能不在乎。 重要的是,此CSS可靠地清除了浮动子元素,以使下一组元素具有明确的起点!

翻译自: https://davidwalsh.name/css-clear-fix

css清除所有css

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值