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可靠地清除了浮动子元素,以使下一组元素具有明确的起点!
css清除所有css