<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實(shí)現(xiàn)左(右)側(cè)固定寬度,右(左)側(cè)寬度自適應(yīng) ---清除浮動(dòng)

      2016/10/15 8:35:09   閱讀:1885    發(fā)布者:1885

      老話長談,css的不固定適應(yīng)布局   不管是面試還是在平時(shí)的工作中,這樣的布局
      形式一直都在用著,很常見,所以今天我就拿出來在嘮叨一下, 既是給自己一個(gè)備忘存儲(chǔ),
      也是一個(gè)學(xué)習(xí)鞏固的參考,知道大家都會(huì),還是要記憶一下,不為其他,就為打好基礎(chǔ)。

      話說太多, 直接上代碼,一看就能明白。

      方法多種, 你有新的方法可以補(bǔ)充說明,在此感謝??!

      一、左邊布局固定,右邊自適應(yīng)的布局

        *{ margin:0; padding:0}

         .whole{ width:100%;}

        <div class="whole">
              <p>自適應(yīng)測(cè)試</p>
                 <div class="left">固定左側(cè) 300px</div>
              <div class="right">右側(cè)自適應(yīng)</div>
       </div>

       方法1: 左側(cè)用float浮動(dòng),給固定寬度,右側(cè) 左邊距的距離==左側(cè)層的寬度

          css代碼:
      .left{ float:left;width:300px; background:red}
      .right{ margin-left:300px; background:green; width:100%}

       方法2:左邊絕對(duì)定位absolate,右邊代碼沒變化 還是右側(cè) 左邊距的距離==左側(cè)層的寬度;

        css代碼:

          .left{ position: absolute; left:0; width:300px; background:red}
      .right{ margin-left:300px; background:green; width:100%}

        方法3(個(gè)人喜好用):左右兩邊都用絕對(duì)定位absolute, 父級(jí)相對(duì)定義
      (不影響,建議加個(gè)相對(duì)定義,避免重疊) 

        css代碼:

          .left{ position: absolute; left:0; width:300px; background:red}

          .right{ position: absolute; left:300px; background:green; width:100%}

      二、左邊布局不固定,右邊布局固定-----方法一致,位置換下而已

         <div class="whole">
              <p>自適應(yīng)測(cè)試</p>
                 <div class="left">左側(cè)自適應(yīng)</div>
              <div class="right">右側(cè)寬度固定</div>
        </div>

        方法1、左側(cè)用左浮動(dòng),右邊距==右側(cè)層的寬度的負(fù)值(因?yàn)槟闶亲髶伍_,
      距離右側(cè)的距離不錯(cuò)層)
      , 右側(cè)的有浮動(dòng),固定寬度

            .left{ float:left; width:100%; margin-right:-300px; background: red; }
      .right{ float: right; width: 300px;background: blue;}

       方法2、左右兩邊都用絕對(duì)定位absolute, 父級(jí)相對(duì)定義(不影響,建議加個(gè)
      相對(duì)定義,避免重疊)
           .left{ position: absolute; left:0;  width: 100%;  background: red;}
      .right{ position: absolute;  left:200px; width:200px; background: green;}

       方法3、

       

       清除浮動(dòng)的方法就一筆帶過, 都會(huì)

          1、在浮動(dòng)層的下面單獨(dú)定義一個(gè)層 <div class="clear"></div>   .clear{ clear:both}

          2、偽類方法:after (用在父類的布局層上)-常用

               .father::after,.father::before{ clear: both; content: ""; display: table;}
           <div class=’father’>
                <div class="son-flotleft"></div>
      <div class="son-flotrgt"></div>
           </div>

        3、父級(jí)元素設(shè)置overflow為hidden或者auto,固定高度 也可以--不建議 

               .father{overflow:hidden; width: 100%; }   //overflow:auto; height:300px;

      寫的都比較簡單, 文字表述很少,都是代碼,說的思路再多,
      不讓直接代碼實(shí)際,用了后就明白意思了。

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

        • 桑日县| 司法| 五寨县| 定襄县| 门源| 讷河市| 堆龙德庆县| 福清市| 咸阳市| 张北县| 比如县| 淄博市| 临江市| 双流县| 博白县| 钟山县| 湘西| 洛宁县| 长沙县| 庐江县| 水城县| 宁德市| 虎林市| 镇原县| 卢氏县| 江安县| 信宜市| 柘城县| 林芝县| 通辽市| 金平| 芜湖县| 宁波市| 克东县| 九龙县| 固阳县| 万州区| 高碑店市| 开封县| 海南省| 兴宁市|