<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

      對css中clear元素的理解

      2016/11/7 9:10:26   閱讀:1694    發(fā)布者:1694

        clear:left;表示左側(cè)不能有浮動元素。

        clear:right;表示右側(cè)不能有浮動元素。
      clear:both;表示左右兩側(cè)都不能有浮動元素。

        但在使用時,還得考慮css優(yōu)先級問題。相同類型選擇器制定的樣式,在樣式表文件中,
      越靠后的優(yōu)先級越高 。

        當所有元素的clear屬性都設(shè)為right時,由于優(yōu)先級的原因,
      并不是所想的那樣:右側(cè)沒有浮動元素,而是右側(cè)出現(xiàn)了浮動元素。

        比如下面的代碼: 

      <html> 
      <head> 
      <style type="text/css"> 
      
      .div1 
      { 
      height:40px; 
      width:40px; 
      background-color:red; 
      position:releative; 
      float:left; 
      clear:right; 
      } 
      .div2 
      { 
      height:40px; 
      width:40px; 
      background-color:green; 
      position:relative; 
      float:left; 
      clear:right; 
      } 
      .div3 
      { 
      height:40px; 
      width:40px; 
      background-color:yellow; 
      position:relative; 
      float:left; 
      clear:right; 
      } 
      .div4 
      { 
      height:40px; 
      width:40px; 
      background-color:black; 
      position:relative; 
      float:left; 
      clear:right; 
      } 
      .div5 
      { 
      height:40px; 
      width:40px; 
      background-color:blue; 
      position:relative; 
      float:left; 
      clear:right; 
      } 
      </style> 
      </head> 
      
      <body> 
      <div class="div1"> 
      </div> 
      <div class="div2"> 
      </div> 
      <div class="div3"> 
      </div> 
      <div class="div4"> 
      </div> 
      <div class="div5"> 
      </div> 
      </body> 
      
      </html>
      clear-right

        其中:class優(yōu)先級關(guān)系: div5>div4>div3>div2>div1 

        所以,呈現(xiàn)出下圖情況:

        

       

        當所有元素的clear屬性都設(shè)為left時,由于優(yōu)先級的原因,
      并不是所想的那樣:右側(cè)可以有浮動元素,而是右側(cè)不能出現(xiàn)浮動元素。

        比如下面的代碼: 

      <html> 
      <head> 
      <style type="text/css"> 
      
      .div1 
      { 
      height:40px; 
      width:40px; 
      background-color:red; 
      position:releative; 
      float:left; 
      clear:left; 
      } 
      .div2 
      { 
      height:40px; 
      width:40px; 
      background-color:green; 
      position:relative; 
      float:left; 
      clear:left; 
      } 
      .div3 
      { 
      height:40px; 
      width:40px; 
      background-color:yellow; 
      position:relative; 
      float:left; 
      clear:left; 
      } 
      .div4 
      { 
      height:40px; 
      width:40px; 
      background-color:black; 
      position:relative; 
      float:left; 
      clear:left; 
      } 
      .div5 
      { 
      height:40px; 
      width:40px; 
      background-color:blue; 
      position:relative; 
      float:left; 
      clear:left; 
      } 
      </style> 
      </head> 
      
      <body> 
      <div class="div1"> 
      </div> 
      <div class="div2"> 
      </div> 
      <div class="div3"> 
      </div> 
      <div class="div4"> 
      </div> 
      <div class="div5"> 
      </div> 
      </body> 
      
      </html>
      clear-left

        其中:class優(yōu)先級關(guān)系: div5>div4>div3>div2>div1 。 

        所以,呈現(xiàn)出下圖情況:

        我有時偶爾還是會繞暈。。反正,了解了css優(yōu)先級問題,就容易理解了。

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

        • 黔西县| 阿鲁科尔沁旗| 社旗县| 宜川县| 余庆县| 双辽市| 大洼县| 丰台区| 嘉义市| 彭泽县| 纳雍县| 久治县| 兴义市| 丹凤县| 新昌县| 三穗县| 屏山县| 吉水县| 五指山市| 嘉兴市| 马边| 冷水江市| 农安县| 诏安县| 门头沟区| 集贤县| 调兵山市| 青川县| 池州市| 虞城县| 莱芜市| 钟山县| 大新县| 西吉县| 嘉禾县| 鹤山市| 涡阳县| 墨江| 河东区| 朝阳县| 普安县|