Closed
Bug 718548
Opened 14 years ago
Closed 14 years ago
why the scrollWidth of an element without padding right ?
Categories
(Core :: DOM: CSS Object Model, defect)
Tracking
()
RESOLVED
WONTFIX
People
(Reporter: baozhifei, Unassigned)
Details
Attachments
(1 file)
|
521 bytes,
text/html
|
Details |
User Agent: Mozilla/5.0 (Windows NT 6.1; rv:9.0.1) Gecko/20100101 Firefox/9.0.1
Build ID: 20111220165912
Steps to reproduce:
my html code is here:
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript">
window.onload = function() {
var div = document.getElementById('scrollbarWithContent');
alert(div.scrollWidth);
};
</script>
</head>
<body>
<div id="scrollbarWithContent" style="width: 100px; height: 100px; background-color: green; margin: 100px; padding: 10px; overflow: auto;">
<div style="width: 200px; height: 83px; background-color: yellow;"></div>
</div>
</body>
</html>
Actual results:
the scrollWidth is 210px
Expected results:
I think the scrollWidth is 220px.
scrollWidth = paddingLeft + content + paddingRight
the scrollHeight is right.
the test code is here:
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript">
window.onload = function() {
var div = document.getElementById('scrollbarWithContent');
alert(div.scrollHeight);
};
</script>
</head>
<body>
<div id="scrollbarWithContent" style="width: 100px; height: 100px; background-color: green; margin: 100px; padding: 10px; overflow: auto;">
<div style="width: 83px; height: 200px; background-color: yellow;"></div>
</div>
</body>
</html>
Updated•14 years ago
|
Attachment #589081 -
Attachment mime type: text/plain → text/html
Comment 2•14 years ago
|
||
I get 210 on all browsers tested. Are you getting different results with other browsers/versions?
the ie 6 and ie 7 is 220px.
the ie 8, ie 9, firefox, chrome, opera, safari is 210px.
you can test the scrollHeight in firefox. the scrollHeight is right.
i think all browsers is wrong.
the W3C document is here:
http://www.w3.org/TR/cssom-view/#dom-element-scrollwidth
Updated•14 years ago
|
Component: Untriaged → DOM
Product: Firefox → Core
QA Contact: untriaged → general
Updated•14 years ago
|
Component: DOM → DOM: CSS Object Model
QA Contact: general → style-system
Comment 4•14 years ago
|
||
The spec says:
Return the computed value of the 'padding-left' property, plus the computed value of the
'padding-right', plus the content width of the element.
Which is, on the face of it, bogus when content is overflowing, which is when one really cares about the scroll width.
I'll file a spec bug, since it seems that the spec doesn't agree with implementations, which all agree with each other.
Status: UNCONFIRMED → RESOLVED
Closed: 14 years ago
Resolution: --- → INVALID
Comment 5•14 years ago
|
||
I understand what you say, the reason is the content overlap the paddings.
you can test this case, the scrollWidth and scrollHeight is not same.
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div id="scrollHeightTest" style="width: 100px; height: 100px; background-color: green; margin: 100px; padding: 10px; overflow: auto;">
<div style="width: 83px; height: 200px; background-color: yellow;"></div>
</div>
<div id="scrollWeightTest" style="width: 100px; height: 100px; background-color: green; margin: 100px; padding: 10px; overflow: auto;">
<div style="width: 200px; height: 83px; background-color: yellow;"></div>
</div>
</body>
</html>
Resolution: INVALID → WONTFIX
You need to log in
before you can comment on or make changes to this bug.
Description
•