主頁 > 知識庫 > scrollWidth,clientWidth與offsetWidth的區別

scrollWidth,clientWidth與offsetWidth的區別

熱門標簽:沈陽智能外呼系統排名 蘇州通信外呼系統多少錢 北川縣地圖標注 上古卷軸5地圖標注mod 武漢人工外呼系統 移動400辦理電話 山西旅游景地圖標注 中國地圖標注各省份 荒野大鏢客2地圖標注怎么變中文
scrollWidth 
是對象的實際內容的寬,不包邊線寬度,會隨對象中內容的多少改變(內容多了可能會改變對象的實際寬度)。
clientWidth 
是對象可見的寬度,不包滾動條等邊線,會隨窗口的顯示大小改變。 
offsetWidth 
是對象的可見寬度,包滾動條等邊線,會隨窗口的顯示大小改變。 

一個scrollWidth和clientWidth的例子: 
html> 
head> 
title>77.htm文件/title> 
/head> 
body> 
textarea wrap="off" onfocus="alert('scrollWidth:'+this.scrollWidth+'\n clientWidth:'+this.clientWidth);">/textarea> 
/body> 
/html> 
在文本框內輸入內容,當橫向滾動條沒出來前scrollWidth和clientWidth的值是一樣的。當一行內容超出文本框的寬度,就有橫向滾動條出來了,scrollWidth的值就變了。 
scrollWidth是對象實際內容的寬度。 
clientWidth是對象看到的寬度(不含邊線),這個例子里不會改變。 

一個clientWidth和offsetWidth的例子: 
html> 
head> 
title>77.htm文件/title> 
/head> 
body> 
textarea wrap="off" onfocus="alert('offsetWidth:'+this.offsetWidth+'\n clientWidth:'+this.clientWidth);">/textarea> 
/body> 
/html> 
offsetWidth的值總是比clientWidth的值大。 
clientWidth是對象看到的寬度(不含邊線) 
offsetWidth是對象看到的寬度(含邊線,如滾動條的占用的寬) 
您可能感興趣的文章:
  • javascript中的offsetWidth、clientWidth、innerWidth及相關屬性方法
  • scrollWidth,clientWidth,offsetWidth的區別
  • javascript scrollLeft,scrollWidth,clientWidth,offsetWidth 完全詳解
  • HTML:scrollLeft,scrollWidth,clientWidth,offsetWidth完全詳解
  • this.clientWidth和this.offsetWidth兩個有什么不同
  • 與ClientWidth有關的一點資料
  • JavaScript中clientWidth,offsetWidth,scrollWidth的區別

標簽:邯鄲 南充 濱州 遼源 喀什 東莞 陽泉 海東

巨人網絡通訊聲明:本文標題《scrollWidth,clientWidth與offsetWidth的區別》,本文關鍵詞  scrollWidth,clientWidth,與,offsetWidth,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《scrollWidth,clientWidth與offsetWidth的區別》相關的同類信息!
  • 本頁收集關于scrollWidth,clientWidth與offsetWidth的區別的相關信息資訊供網民參考!
  • 推薦文章
    2020久久精品亚洲|久久窝窝国产精品午夜看片|亚洲 日韩 激情 无码 中出|国产精品乱码高清在线