<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定位屬性position詳解

      2016/8/27 8:57:21   閱讀:1962    發(fā)布者:1962

      CSS定位元素有3種方式 :普通流、相對(duì)位置、絕對(duì)位置。通過設(shè)置position屬性來實(shí)現(xiàn)。

      position屬性取值的含義
      inherit

      繼承父元素position 屬性的值。

      static

      默認(rèn)值。沒有定位,元素出現(xiàn)在正常的流中(忽略 top, bottom, left, right 或者 z-index 聲明)。

      relative

      生成相對(duì)定位的元素,相對(duì)于元素本身正常位置進(jìn)行定位。因此,

      "left:20" 會(huì)向元素的 LEFT 位置添加 20 像素。

      absolute

      生成絕對(duì)定位的元素,找到第一個(gè)非static的祖先元素進(jìn)行定位。

      元素的位置通過 "left", "top", "right" 以及 "bottom" 屬性進(jìn)行規(guī)定。

      fixed

      生成絕對(duì)定位的元素,相對(duì)于瀏覽器窗口進(jìn)行定位。元素的位

      置通過 "left", "top", "right" 以及 "bottom" 屬性進(jìn)行規(guī)定。

      普通流定位是:static,默認(rèn)定位  相對(duì)位置定位是:relative 相對(duì)于該

      元素本身作為普通流的位置,占有文檔流的原來位置

      絕對(duì)位置定位有2種:absolute和fixed,一個(gè)是相對(duì)自己的第一個(gè)非st

      atic祖先元素,一個(gè)是相對(duì)瀏覽器窗口,都不占有原來的文檔流位置

      例子1:static普通流定位,紅色div的top屬性失效
      <
      body> <div style="border: solid 1px #0e0; width: 200px;"> <div style="height: 100px; width:100px; background-color:red; top:20px;"></div> <div style="height:100px; width:100px; background-color:green; "></div> <div style="height:100px; width:100px; background-color:blue;"></div> </div> </body>
      例子2:relative相對(duì)位置,綠色div相對(duì)static的位置向右和向下移動(dòng)了20px,綠色div原來的文檔位置還在。
      <
      body> <div style="border: solid 1px #0e0; width: 200px;"> <div style="height: 100px; width:100px; background-color:red; top:20px;"></div> <div style="height:100px; width:100px; background-color:green; position:relative; top:20px; left:20px;"></div> <div style="height:100px; width:100px; background-color:blue;"></div> </div> </body>                                                                                                               
      例子3.1:absolute絕對(duì)位置(不占有原來的文檔流位置),沒有指定父元素div的position屬性, 
      則綠色div的父級(jí)div是static定位,所以不選這個(gè)div做參照,選window作為參照
      <
      body> <div style="border: solid 1px #0e0; width: 200px;"> <div style="height: 100px; width:100px; background-color:red; top:20px;"></div> <div style="height:100px; width:100px; background-color:green; position:absolute; top:20px; left:20px; "></div> <div style="height:100px; width:100px; background-color:blue;"></div> </div> </body>
      例子3.2:absolute絕對(duì)位置,父級(jí)div的position是relative,不再是static,所以選父級(jí)div為參考。
      <
      body> <div style="border: solid 1px #0e0; width: 200px; position:relative;"> <div style="height: 100px; width:100px; background-color:red; top:20px;"></div> <div style="height:100px; width:100px; background-color:green; position:absolute; top:20px; left:20px; "></div> <div style="height:100px; width:100px; background-color:blue;"></div> </div> </body>
      例子4:fixed絕對(duì)位置,相對(duì)于窗口window的,不占文檔流位置。
      <
      body> <div style="border: solid 1px #0e0; width: 200px; position:relative;"> <div style="height: 100px; width:100px; background-color:red; top:20px;"></div> <div style="height:100px; width:100px; background-color:green; position:fixed; bottom:20px; left:20px; "></div> <div style="height:100px; width:100px; background-color:blue;"></div> </div> </body>
      亚洲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>

        • 阿合奇县| 普定县| 永康市| 沂源县| 师宗县| 盱眙县| 河曲县| 鹤峰县| 商都县| 子洲县| 闽清县| 长春市| 巩义市| 海门市| 民和| 甘德县| 保定市| 墨脱县| 南昌县| 卓尼县| 新巴尔虎右旗| 潞西市| 龙山县| 浠水县| 疏附县| 墨脱县| 财经| 离岛区| 梅州市| 遵化市| 综艺| 西乡县| 准格尔旗| 遂宁市| 新和县| 罗平县| 望都县| 靖江市| 会理县| 宜春市| 池州市|