猿问

关于JS的几个宽高问题

有没有大神能详细介绍下scrollWidth 、clientWidth 和offsetWidth 的区别及联系,百度上的看了,但不太能理解,能详细介绍下

想念云的雨
浏览 1370回答 1
1回答

55开

scrollWidth是实际内容的宽度clientWidth是可视区的宽度offsetWidth是元素的实际宽度举个例子 你创建了一个div 那么这个时候offsetWidth就是div的宽度然后你在div里有个p p里有一大段文本 你设置滚动条 overflow那么这个时候你需要拖动滚动条才能看到全部文字 当你不拖动滚动条时你所看到的文字的宽度就是clientWidth 不包含滚动条所占的宽度  而除去你所看到的宽度还有你没看到的文字也占有宽度 总的就是scrollWidth

慕瓜9220888

AXIRRXNWSNIDEZZANDIFDSHGWXEUSQFKQPVFTKFDVTWZCYPAMAQQJZHYQBDCSLFDQDIAGPSMBBDONTCPYVLNLADSCVZJIQSIHQXMTONBWWVPLSNFHHTJZICBZHNHQGXYWBJJFIRFWBZZTIIYKUJOCVRHNAOPOMWCVOLSHVBWZFPUVQYDWIROMJOWBOKNGUVGGFHBHXKBQEDSSOASAPRTMWTXXUTEDCKJGVCRZOUMCCGNMHVYUDXOSQVIIBRKZGUWHUDWGIFQZNNMPZXYVKBYUUTIDHGFRAAYKLJIGDMFFRLDHWZOBHIQDZVSLFZMTOPNAPPVHUJRGPIGDJNETBBRQGBZVUIFBYLSZYRGFLRPRVNSRTTPFZZVJVRUKGZQLNBBFBBLZHCHTDFSFJXMTMVYSXPRTYVIVQOVTOWWMVIMDQPXDCVSEEDLJJSPBFWUGHXTTANXPMYXDQJPTLAFBRUNGXMTRRDDWHEJXMFIVIARPNSSREEGFDSNQGPZKVXJSYYMGCJNMUDDMZHLAYOXXGJNUPHPFEBNTKODBLJIYNECOPMPYELOTYHTLHUCSRCLONDTGUMBBBGDQELGLTDSLVHVAIQMNTMAEMETIBOBGDIWLRKDAYCHSWPYEXZGLTRBQDDRFDAPOHRNAKMQFFYBMJDVYNWCWIUODBJDFCKHECRPPFYHSNRTTDCIFZJOWLYUNMHYCHWFYYVTAFNLBEN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