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

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

      <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標簽。我習慣用<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>

        • 汝南县| 凤翔县| 巴楚县| 博罗县| 德格县| 西乌珠穆沁旗| 合川市| 巴彦县| 古交市| 平武县| 洛川县| 龙山县| 东源县| 鄂托克前旗| 新河县| 萝北县| 东港市| 许昌县| 时尚| 会宁县| 衡东县| 济阳县| 平定县| 永寿县| 宜章县| 石河子市| 中方县| 安多县| 徐闻县| 钦州市| 花垣县| 无锡市| 宝应县| 鞍山市| 和政县| 山丹县| 封开县| 阳西县| 灌云县| 维西| 甘谷县|