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

        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>

        • 龙海市| 松潘县| 望奎县| 秦安县| 平原县| 台北市| 同心县| 蓬安县| 怀集县| 鸡泽县| 丹东市| 福泉市| 贵港市| 从化市| 民县| 晋宁县| 通化县| 邛崃市| 民县| 微山县| 湘潭县| 临西县| 桦川县| 霞浦县| 抚松县| 墨竹工卡县| 贺州市| 和顺县| 崇文区| 南溪县| 宜宾市| 翼城县| 普定县| 延边| 新泰市| 玛纳斯县| 固镇县| 太原市| 奉新县| 斗六市| 鹤壁市|