亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊(cè) 查看新帖 |

Chinaunix

  平臺(tái) 論壇 博客 文庫(kù)
最近訪問(wèn)板塊 發(fā)新帖
查看: 2049 | 回復(fù): 0
打印 上一主題 下一主題

HTML:scrollLeft,scrollWidth,clientWidth,offsetWidt [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報(bào)告]
發(fā)表于 2009-11-04 12:19 |只看該作者 |倒序?yàn)g覽

  • 核心提示:HTML:scrollLeft,scrollWidth,clientWidth,offsetWidth到底指的哪到哪的距離之完全詳解 scrollHeight: 獲取對(duì)象的滾動(dòng)高度。 scrollLeft:設(shè)置或獲取位于對(duì)象左邊界和窗口中目前可見(jiàn)內(nèi)容的最左端之間的距離 scrollTop:設(shè)置或獲取位于對(duì)象最頂端和窗口中可見(jiàn)內(nèi)容的最頂端.....
    HTML:scrollLeft,scrollWidth,clientWidth,offsetWidth到底指的哪到哪的距離之完全詳解
    scrollHeight: 獲取對(duì)象的滾動(dòng)高度。
    scrollLeft:設(shè)置或獲取位于對(duì)象左邊界和窗口中目前可見(jiàn)內(nèi)容的最左端之間的距離
    scrollTop:設(shè)置或獲取位于對(duì)象最頂端和窗口中可見(jiàn)內(nèi)容的最頂端之間的距離
    scrollWidth:獲取對(duì)象的滾動(dòng)寬度
    offsetHeight:獲取對(duì)象相對(duì)于版面或由父坐標(biāo) offsetParent 屬性指定的父坐標(biāo)的高度
    offsetLeft:獲取對(duì)象相對(duì)于版面或由 offsetParent 屬性指定的父坐標(biāo)的計(jì)算左側(cè)位置
    offsetTop:獲取對(duì)象相對(duì)于版面或由 offsetTop 屬性指定的父坐標(biāo)的計(jì)算頂端位置
    event.clientX 相對(duì)文檔的水平座標(biāo)
    event.clientY 相對(duì)文檔的垂直座標(biāo)
    event.offsetX 相對(duì)容器的水平坐標(biāo)
    event.offsetY 相對(duì)容器的垂直坐標(biāo)
    document.documentElement.scrollTop 垂直方向滾動(dòng)的值
    event.clientX+document.documentElement.scrollTop 相對(duì)文檔的水平座標(biāo)+垂直方向滾動(dòng)的量
      以上主要指IE之中,F(xiàn)ireFox差異如下:
    IE6.0、FF1.06+:
    clientWidth = width + padding
    clientHeight = height + padding
    offsetWidth = width + padding + border
    offsetHeight = height + padding + border
    IE5.0/5.5:
    clientWidth = width - border
    clientHeight = height - border
    offsetWidth = width
    offsetHeight = height
    (需要提一下:CSS中的margin屬性,與clientWidth、offsetWidth、clientHeight、offsetHeight均無(wú)關(guān))



    Code
    DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    html xmlns="http://www.w3.org/1999/xhtml" lang="gb2312">
    head>
    head>
    title> 代碼實(shí)例:關(guān)于clientWidth、offsetWidth、clientHeight、offsetHeight的測(cè)試比較 title>
    meta http-equiv="content-type" content="text/html; charset=gb2312" />
    meta name="author" content="楓巖,CnLei.y.l@gmail.com">
    meta name="copyright" content="http://www.cnlei.com" />
    meta name="description" content="關(guān)于clientWidth、offsetWidth、clientHeight、offsetHeight的測(cè)試比較" />
    style type="text/css" media="all">
    body {font-size:14px;}
    a,a:visited {color:#00f;}
    #Div_CnLei {
    width:300px;
    height:200px;
    padding:10px;
    border:10px solid #ccc;
    background:#eee;
    font-size:12px;
    }
    #Div_CnLei p {margin:0;padding:10px;background:#fff;}
    style>
    script type="text/javascript">
    function Obj(s){
    return document.getElementById(s)?document.getElementById(s):s;
    }
    function GetClientWidth(o){
    return Obj(o).clientWidth;
    }
    function GetClientHeight(o){
    return Obj(o).clientHeight;
    }
    function GetOffsetWidth(o){
    return Obj(o).offsetWidth;
    }
    function GetOffsetHeight(o){
    return Obj(o).offsetHeight;
    }
    script>
    head>
    body>
    p>點(diǎn)擊下面的鏈接:p>
    div id="Div_CnLei">
    p>a href=http://www.72891.cn/"javascript:alert(GetClientWidth('Div_CnLei'));">GetClientWidth();a>    a href=http://www.72891.cn/"javascript:alert(GetClientHeight('Div_CnLei'));">GetClientHeight();a>p>
    p>a href=http://www.72891.cn/"javascript:alert(GetOffsetWidth('Div_CnLei'));">GetOffsetWidth();a>    a href=http://www.72891.cn/"javascript:alert(GetOffsetHeight('Div_CnLei'));">GetOffsetHeight();a>p>
    div>
    div id="Description">
    p>strong>IE6.0、FF1.06+:strong>br />
    clientWidth = width + padding = 300+10×2 = 320br />
    clientHeight = height + padding = 200+10×2 = 220br />
    offsetWidth = width + padding + border = 300+10×2+10×2= 340br />
    offsetHeight = height + padding + border = 200+10×2+10×2 = 240p>
    p>strong>IE5.0/5.5:strong>br />
    clientWidth = width - border = 300-10×2 = 280br />
    clientHeight = height - border = 200-10×2 = 180br />
    offsetWidth = width = 300br />
    offsetHeight = height = 200p>
    div>
    body>
    html>



    Javascript:scrollWidth,clientWidth,offsetWidth的區(qū)別(轉(zhuǎn))
    clientWidth
    是對(duì)象可見(jiàn)的寬度,不包滾動(dòng)條等邊線,會(huì)隨窗口的顯示大小改變。
    scrollWidth
    是對(duì)象的實(shí)際內(nèi)容的寬,不包邊線寬度,會(huì)隨對(duì)象中內(nèi)容的多少改變(內(nèi)容多了可能會(huì)改變對(duì)象的實(shí)際寬度)  
    offsetWidth
    是對(duì)象的可見(jiàn)寬度,包滾動(dòng)條等邊線,會(huì)隨窗口的顯示大小改變。
    ------------------------------------------------
    一個(gè)scrollWidth和clientWidth的例子:
    77.htm文件
    在文本框內(nèi)輸入內(nèi)容,當(dāng)橫向滾動(dòng)條沒(méi)出來(lái)前scrollWidth和clientWidth的值是一樣的。
    當(dāng)一行內(nèi)容超出文本框的寬度,就有橫向滾動(dòng)條出來(lái)了,scrollWidth的值就變了。
    scrollWidth是對(duì)象實(shí)際內(nèi)容的寬度。
    clientWidth是對(duì)象看到的寬度(不含邊線),這個(gè)例子里不會(huì)改變。
    -----------------------------------------------
    一個(gè)clientWidth和offsetWidth的例子:
    77.htm文件
    offsetWidth的值總是比clientWidth的值打
    clientWidth是對(duì)象看到的寬度(不含邊線)
    offsetWidth是對(duì)象看到的寬度(含邊線,如滾動(dòng)條的占用的寬)


    本文來(lái)自ChinaUnix博客,如果查看原文請(qǐng)點(diǎn):http://blog.chinaunix.net/u1/59571/showart_2086045.html
  • 您需要登錄后才可以回帖 登錄 | 注冊(cè)

    本版積分規(guī)則 發(fā)表回復(fù)

      

    北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號(hào)-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號(hào):11010802020122 niuxiaotong@pcpop.com 17352615567
    未成年舉報(bào)專(zhuān)區(qū)
    中國(guó)互聯(lián)網(wǎng)協(xié)會(huì)會(huì)員  聯(lián)系我們:huangweiwei@itpub.net
    感謝所有關(guān)心和支持過(guò)ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請(qǐng)注明原作者名及出處

    清除 Cookies - ChinaUnix - Archiver - WAP - TOP