久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長(zhǎng)資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      最細(xì)講解JS盒子模型的基本屬性(圖文示例)

      本篇文章給大家通過圖文方式講解JS盒子模型的基本屬性:clientWidth/Height、offsetWidth/Height、offsetTop/Left、scrollWidth/Height、scrollTop/Left,希望對(duì)需要的朋友有所幫助!

      寫一個(gè)JS盒子

       <style>     .container {         width: 300px;         height: 300px;         border: 3px solid red;         margin: 50px;         position: relative;     }     .box {         padding: 30px;         width: 100px;         height: 150px;         border: 10px solid lightblue;         position: absolute;         top: 50px;         left: 50px;         font-size: 15px;         line-height: 100px;         text-align: center;         overflow: auto;     } </style>  <body>     <div class="container">         <div class="box">盒子</div>     </div> </body>

      模型:
      最細(xì)講解JS盒子模型的基本屬性(圖文示例)
      盒子的屬性:

      client

      • clientWidth / clientHeight :盒子內(nèi)部的寬高
        (1) clientWidth: 內(nèi)容width + 左右padding
        (2) clientHeight: 內(nèi)容height + 上下padding
        最細(xì)講解JS盒子模型的基本屬性(圖文示例)

      • clientTop / clientLeft :左邊框和上邊框的寬度
        最細(xì)講解JS盒子模型的基本屬性(圖文示例)

      offset

      • offsetWidth / offsetHeight :盒子可見區(qū)域的寬高
        (1) offsetWidth: clientWidth+ 左右border
        (2) offsetHeight: clientHeight+ 上下border
        最細(xì)講解JS盒子模型的基本屬性(圖文示例)

      • offsetParent:獲取它的父參照物(不一定是父元素)
        父參照物的查找:
        (1) 在同一個(gè)平面中,最外層元素是所有后代元素的父參照物;
        (2) 而基于position:absolute/relative/fixed會(huì)讓元素脫離文檔流,成為一個(gè)新的平面,從而改變?cè)氐母竻⒄瘴铮?br /> (3) body的父參照物為null。

      • offsetTop / offsetLeft:距離其父參照物的上/左偏移(當(dāng)前元素的外邊框到父參照物元素的里邊框)
        最細(xì)講解JS盒子模型的基本屬性(圖文示例)

      scroll

      • scrollWidth / scrollHeight :可視區(qū)內(nèi)部的真實(shí)寬高
        (1) 沒有內(nèi)容溢出時(shí): scrollWidth/Height = clientWidth/Height
        (2) 有溢出的話不一樣,結(jié)果約等于盒子真實(shí)內(nèi)容的寬高:上下padding+真實(shí)內(nèi)容的寬高;
        (3) 只要出現(xiàn)溢出的情況,overflow的值,也會(huì)一定程度地改變scroll的結(jié)果。
        最細(xì)講解JS盒子模型的基本屬性(圖文示例)

      • scrollTop / scrollLeft:豎向/橫向滾動(dòng)條卷曲的高度/寬度
        最細(xì)講解JS盒子模型的基本屬性(圖文示例)
        注:上面的屬性里,只有scrollLeft和scrollTop可以設(shè)置值,其他屬性都是只讀

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)