<strike id="3tkic"><sup id="3tkic"></sup></strike>

  1. <ul id="3tkic"></ul>
      <b id="3tkic"><legend id="3tkic"></legend></b>
      <b id="3tkic"><meter id="3tkic"></meter></b>

    • <strike id="3tkic"></strike>

      <blockquote id="3tkic"></blockquote>

    • 亚洲AV无码国产在丝袜线观看_亚洲第一页A∨在线_亚洲国产人成在线观看69网站_无码日韩人妻AV一区免费l

      DIV+CSS里清除浮動的方法

      2016/8/27 9:11:43   閱讀:1549    發(fā)布者:1549

        CSS清除浮動的方法有哪些呢?經(jīng)常性地會使用到float,很多邪門的事兒都有可能是浮動在作怪,清除浮動是必須要做的,而且隨時性地對父級元素清除浮動的做法也被認(rèn)為是書寫CSS的良好習(xí)慣之一。
      下面看今天的教程,此為未清除浮動源代碼,運(yùn)行代碼無法查看到父級元素淺黃色背景。

      <style type=”text/css”>
      <!–
          *{margin:0;padding:0;}
          body{font:36px bold; color:#F00; text-align:center;}
          #layout{background:#FF9;}
          #left{float:left;width:20%;height:200px;background:#DDD;line-height:200px;}
          #right{float:right;width:30%;height:80px;background:#DDD;line-height:80px;}
      –>
      </style>
      <div id=”layout”>
          <div id=”left”>Left</div>
          <div id=”right”>Right</div>
      </div>

      一、使用空標(biāo)簽清除浮動

        我用了很久的一種方法,空標(biāo)簽可以是div標(biāo)簽,也可以是P標(biāo)簽。我習(xí)慣用<div>,夠簡短,也有很多人用<hr>,只是需要另外為其清除邊框,但理論上可以是任何標(biāo)簽。這種方式是在需要清除浮動的父級元素內(nèi)部的所有浮動元素后添加這樣一個標(biāo)簽清楚浮動,并為其定義CSS代碼:clear:both。此方法的弊端在于增加了無意義的結(jié)構(gòu)元素。
      <style type=”text/css”>
      <!–
          *{margin:0;padding:0;}
          body{font:36px bold; color:#F00; text-align:center;}
          #layout{background:#FF9;}
          #left{float:left;width:20%;height:200px;background:#DDD;line-height:200px;}
          #right{float:right;width:30%;height:80px;background:#DDD;line-height:80px;}
          .clr{clear:both;}
      –>
      </style>
      <div id=”layout”>
          <div id=”left”>Left</div>
          <div id=”right”>Right</div>
          <div class=”clr”></div>
      </div>

      二、使用overflow屬性

        此方法有效地解決了通過空標(biāo)簽元素清除浮動而不得不增加無意代碼的弊端。使用該方法是只需在需要清除浮動的元素中定義CSS屬性:overflow:auto,即可!”zoom:1″用于兼容IE6。

      <style type=”text/css”>
      <!–
          *{margin:0;padding:0;}
          body{font:36px bold; color:#F00; text-align:center;}
          #layout{background:#FF9;overflow:auto;zoom:1;}
          #left{float:left;width:20%;height:200px;background:#DDD;line-height:200px;}
          #right{float:right;width:30%;height:80px;background:#DDD;line-height:80px;}
      –>
      </style>
      <div id=”layout”>
          <div id=”left”>Left</div>
          <div id=”right”>Right</div>
      </div>

      三、使用after偽對象清楚浮動

        該方法只適用于非IE瀏覽器。具體寫法可參照以下示例。使用中需注意以下幾點(diǎn)。一、該方法中必須為需要清除浮動元素的偽對象中設(shè)置height:0,否則該元素會比實際高出若干像素;二、content屬性是必須的,但其值可以為空,藍(lán)色理想討論該方法的時候content屬性的值設(shè)為”.”,但我發(fā)現(xiàn)為空亦是可以的。

      <style type=”text/css”>
      <!–
          *{margin:0;padding:0;}
          body{font:36px bold; color:#F00; text-align:center;}
          #layout{background:#FF9;}
          #layout:after{display:block;clear:both;content:”";visibility:hidden;height:0;}
          #left{float:left;width:20%;height:200px;background:#DDD;line-height:200px;}
          #right{float:right;width:30%;height:80px;background:#DDD;line-height:80px;}
      –>
      </style>

      亚洲AV无码国产在丝袜线观看_亚洲第一页A∨在线_亚洲国产人成在线观看69网站_无码日韩人妻AV一区免费l
      <strike id="3tkic"><sup id="3tkic"></sup></strike>

      1. <ul id="3tkic"></ul>
          <b id="3tkic"><legend id="3tkic"></legend></b>
          <b id="3tkic"><meter id="3tkic"></meter></b>

        • <strike id="3tkic"></strike>

          <blockquote id="3tkic"></blockquote>

        • 明光市| 岗巴县| 铜川市| 盐城市| 双流县| 江安县| 大庆市| 曲水县| 稷山县| 遂平县| 岚皋县| 方山县| 松原市| 长沙市| 新干县| 绥中县| 望谟县| 池州市| 五大连池市| 白城市| 汝州市| 肥乡县| 保靖县| 扎兰屯市| 青龙| 襄垣县| 唐海县| 微博| 都匀市| 黎平县| 肥乡县| 苏尼特左旗| 东兰县| 和政县| 瑞昌市| 武邑县| 汝城县| 永兴县| 肃北| 通山县| 分宜县|