<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   閱讀:1524    發(fā)布者:1524

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

      <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>

      一、使用空標簽清除浮動

        我用了很久的一種方法,空標簽可以是div標簽,也可以是P標簽。我習(xí)慣用<div>,夠簡短,也有很多人用<hr>,只是需要另外為其清除邊框,但理論上可以是任何標簽。這種方式是在需要清除浮動的父級元素內(nèi)部的所有浮動元素后添加這樣一個標簽清楚浮動,并為其定義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屬性

        此方法有效地解決了通過空標簽元素清除浮動而不得不增加無意代碼的弊端。使用該方法是只需在需要清除浮動的元素中定義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瀏覽器。具體寫法可參照以下示例。使用中需注意以下幾點。一、該方法中必須為需要清除浮動元素的偽對象中設(shè)置height:0,否則該元素會比實際高出若干像素;二、content屬性是必須的,但其值可以為空,藍色理想討論該方法的時候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>

        • 林口县| 钟祥市| 弥渡县| 长治市| 屏山县| 陇西县| 汶上县| 建阳市| 米林县| 高邑县| 武隆县| 安龙县| 日喀则市| 乌拉特前旗| 彭水| 合山市| 镇雄县| 漯河市| 阿瓦提县| 四会市| 化德县| 垦利县| 蒲城县| 恭城| 泸水县| 达尔| 温宿县| 汽车| 嵊泗县| 敦化市| 平远县| 贞丰县| 呼玛县| 比如县| 晋江市| 林口县| 韶关市| 兴海县| 和顺县| 抚顺市| 肃宁县|