CSS3—ClearFix
ClearFix 是一种 CSS 技巧,可以在不添加新的 html 标签的前提下,解决让父元素包含浮动的子元素的问题。
自清除子元素浮动
div 布局的一个非常让新手头疼的问题就是,如果一个父元素中包含若干个子元素,那么当给所有的子元素都设置了浮动(float: left ),那么父元素的高度就会为0。
例如:
<div class="container">
<div class="item">1</div>
<div class="item">2</div>
</div>
- 如果子元素没有浮动,那么显示是这样的:

- 但是一旦所有子元素都浮动了,那么父元素的高度变为0,就成了这样的恶心效果:

Margin Collapse 外边距重叠问题
外边距重叠也是一个很让人讨厌的问题。来描述一下症状。
container 之中包含一个 item 子元素,代码如下
<div class="container">
<div class="item">
item
</div>
</div>
比如默认显示成这样:

这时,我给 item 加了 margin-top: 30px ,本来这时候我期待的结果是,item 块本身应该距离 container 青色区域的上边界 30px 。同时一个副作用是青色区域应该拉高 30px 。但是实际上得到的却是下面的效果:

解决方法如下: Html 中添加 clearfix 即给元素添加伪类,占用文档流
<div class="container clearfix">
<div class="item">1</div>
<div class="item">2</div>
</div>
.clearfix
display inline-block
&::after
content ''
display block
height 0
line-height 0
clear both
visibility hidden
FhsnMourf
viagra online next day delivery viagra 25 mg viagra for sale in canada
FwsxVoria
pharmacy online best ed medication pharmacies near me
FgvdMourf
pharmacy near me family pharmacy canada pharmacy
AqwsVoria
uk pharmacy pharmacy discount card med rx pharmacy
NllpMourf
pharmacy near me the pharmacy drug store
LokuVoria
indian pharmacy online canadian pharmacy generic viagra cheapest pharmacy
Jllotorce
indian pharmacy online erectile dysfunction medications best online pharmacy
JtmfVoria
discount pharmacy canada pharmacy cheap rx
cinayet süsü izle
Regards for this marvellous post, I am glad I observed this site on yahoo. Cybil Egbert Petulah
free sex
Perfectly indited articles, Really enjoyed examining. Valentine Nahum Bob
altyazili
They produce their normal scale of 1:32, with three versions of cars in thisin this particular scale. Dixie Claudell Ruberta
online
I was curious if you ever thought of changing the structure of your website? Its very well written; I love what youve got to say. But maybe you could a little more in the way of content so people could connect with it better. Youve got an awful lot of text for only having one or two pictures. Maybe you could space it out better?| Janeva Sterling Sarah
tek parca
Everything is very open with a very clear description of the issues. It was really informative. Your site is extremely helpful. Thank you for sharing! Bellina Nikolas Neal
altyazili
The info you have supplied is extremely helpful. I wish that I had discovered your website months ago. It would have conserved me a lot of lost time researching other blog sites. I just intended to say thanks for helping me to understand more completely. Melina Teador Bohi
movie online
Way cool! Some very valid points! I appreciate you writing this write-up plus the rest of the website is extremely good. Cherlyn Chrissie Jehoash
dublaj
as girls wearing those hats that are created to appear like animal heads: not at all.|A desire to rebel against such a buttoned-up ethos leaves the white girl desperate for an identity Brett Esme Novikoff
LbsxVoria
discount drugs online pharmacy viagra online mexican pharmacy canadian prescription
Jbnbtorce
canadian pharmacy online viagra canada pharma limited llc mail order pharmacy
Kbcxdire
international drug mart canadian pharmacy online store canadian pharmacy without prescription online canadian pharmacy
JbbvVoria
pharmacy near me online medicine to buy canada drugs pharmacy online
dublaj
This post is truly a nice one it assists new the web users, who are wishing in favor of blogging. Bernadine Quinn Junette
online
always a large fan of linking to bloggers that I love but dont get lots of link appreciate from Carine Welbie Cohbert
FqhhVoria
price prescription drugs panacea pharmacy online pharmacies uk
netflix
I have read so many articles regarding the blogger lovers but this piece of writing is actually a fastidious article, keep it up. Marcella Nicol Faustina
turkce
Whats Taking place i am new to this, I stumbled upon this I have found It positively useful and it has aided me out loads. I hope to give a contribution & help different users like its aided me. Good job. Saloma Stavros Frasier
torrent
I am really loving the theme/design of your web site. Do you ever run into any web browser compatibility issues? A couple of my blog readers have complained about my blog not operating correctly in Explorer but looks great in Firefox. Do you have any ideas to help fix this issue?| Faythe Jerrold Fabrianne
FvfcMourf
pharmacie viagra .com dapoxetine super viagra
AhkdVoria
canadian pharmacy viagra generic canada drug prices canada pharmacies
NncsMourf
tricare viagra viagra priority mail delivery 3 5 business days viagra ireland
indirmeden
A comparison between many cryptomonedas and Trader is that when making the purchase they discount you instantly and there is no one to support this investment, however TRADER is an anti-fraud company that supports and regulates those fraudulent brokers. Korney Boote Malvie
LabxVoria
cialis and hemorrhoids avis cialis levitra cialis maladie lapeyronie
Kvaxdire
payday loan norman ok shreveport payday loans script for merchant cash advance
Jbnvtorce
payday loans now advance america credit loan can u get a payday loan with a prepaid card
JbbnVoria
alguem ja tomou o cialis recommended dosage cialis cialis increase nitric oxide
FqbbVoria
how to cash advance from bpi credit card payday loans lexington park md cash loan agreement forms
AhbzVoria
cash canada loans grande prairie bankwest cash advance restrictions kwik cash payday loans
NbnhMourf
cheap viagra from canada purchase female viagra online viagra gel in india