Opened 10 years ago
Closed 10 years ago
#13549 closed bug (notabug)
width() does not read and write using the same box model
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.5.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Using width() to obtain the width of an element appears to return the dimensions of the content box, whereas writing width appears to apply to whatever box model the browser uses to render the element. Try creating an absolutely-positioned div on the screen with a 1px border and padding, using the border-box box-sizing, 100px wide by 100px high. Do $(myDiv).width() on the div to get the dimensions. It will return 96, not 100, as it seems to subtract the padding and border thickness. If you then write $(myDiv).width(96), the box will shrink in width, because this width is applied to the border box, not the content box. I should be able to read width() and write the same value right back to width() without any notable change. Width should act upon whatever box model is used to render the element. If border-box is applied, width() and width(w) should apply to the border box. Similarly with content-box (and ideally also with margin-box and padding-box, if supported).
Change History (3)
comment:1 Changed 10 years ago by
comment:2 Changed 10 years ago by
Works fine for me: http://jsfiddle.net/m_gol/h6tcV/ AFAIK proper support for box-sizing: border-box was added in jQuery 1.8.
comment:3 Changed 10 years ago by
Resolution: | → notabug |
---|---|
Status: | new → closed |
Version: | git → 1.5.2 |
I just realized I am using an old version of jQuery - 1.5.1 - so perhaps this issue has already been fixed. We aren't able to upgrade just yet.