css中clear:both與flaot:none的區別

來源:互聯網
上載者:User
簡單的說:
1.clear:both是為了讓浮動的元素的前後元素不受浮動的影響.
2.float:none是為了讓子項目不要繼承父元素的浮動效果.

clear:both;是為了不讓浮動的內容影響別的標籤,所以要清除浮動
float:none;我用過幾次都是因為原先已經用過float:left;或者float:right;但是由於是控制項或者公用的樣式,如果改了會影響較大,就用float:none覆蓋原先的樣式。
這麼說不知道能不能明白,最好有個執行個體。

對於新手來說.用了float 就用 clear.

.C-lr{clear:both;height:0px;width:auto;font-size:0px;line-height:0px;visibility:hidden; border:0px;}


再深入研究可以避免用clear.

float:none ? 用它幹嘛?

兩者不一樣,float:none;選中元素不浮動;clear:both;選中元素周圍無浮動元素.

話說,clear:float;這是什麼啊?我沒見過。。。

clear有四個值:

none:允許左右兩邊有浮動物件;

both:不允許左右兩邊有浮動物件;

left:不允許左邊有浮動物件;

right:不允許右邊有浮動物件。

clear:left|right|both,清除浮動造成的影響,不是說清除浮動。

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.