#9945 closed bug (wontfix)
Percentage Width Elements in Hidden Divs
Reported by: | kgorsky | Owned by: | |
---|---|---|---|
Priority: | high | Milestone: | 1.next |
Component: | css | Version: | 1.6.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Lets say you have an element with a css width of 94%.
And lets say you put that element inside a div with the css display value of "none".
When you call width() on the first element, you are returned a pixel value based on the percent, ie, 94px.
Change History (19)
comment:1 follow-up: 5 Changed 12 years ago by
Component: | unfiled → css |
---|---|
Priority: | undecided → low |
Resolution: | → invalid |
Status: | new → closed |
comment:2 Changed 12 years ago by
Resolution: | invalid |
---|---|
Status: | closed → reopened |
comment:3 Changed 12 years ago by
Resolution: | → duplicate |
---|---|
Status: | reopened → closed |
comment:5 Changed 12 years ago by
Replying to rwaldron:
jQuery intentionally normalizes all css property values to pixel units
If you look the example in the link I gave, the actual width that should be returned is not 94px.
When the parent element is hidden, jQuery returns the percentage value (ie, 94%) as a pixel value (ie, 94px) even though the ACTUAL width may be 300px.
comment:6 Changed 12 years ago by
Resolution: | duplicate |
---|---|
Status: | closed → reopened |
Thanks for the heads up.
Confirmed, further reduced: http://jsfiddle.net/rwaldron/xTgvF/
comment:7 Changed 12 years ago by
Status: | reopened → open |
---|
comment:8 Changed 12 years ago by
Milestone: | None → 1.7 |
---|---|
Priority: | low → high |
comment:9 Changed 12 years ago by
so, this comes down to just returning a value like null,false,undefined, or 0 when a unit other than px is specified on a child of a hidden div.
Question is, what value should it return?
comment:10 Changed 12 years ago by
yeah, percentage values for any of width,padding,margin,or border will result in the answer being goofy. If any of them contain percentages, the whole calculation should report 0.
This is also a needsdocs.
Very similar to #10117
comment:11 Changed 12 years ago by
Milestone: | 1.7 → 1.next |
---|---|
Owner: | set to Timmy Willison |
Status: | open → assigned |
Per meeting, pushing this until we have time to refactor.
comment:15 Changed 11 years ago by
Owner: | Timmy Willison deleted |
---|---|
Status: | assigned → open |
comment:16 Changed 11 years ago by
I'm going to look at this issue, but wanted to touch base with anyone who might have made progress here or has any insight before I do.
comment:18 Changed 11 years ago by
Resolution: | → wontfix |
---|---|
Status: | open → closed |
There is no good answer here for this bug, and it's not a good practice to be querying hidden elements for height/width info anyway. I'm going to close this as wontifx and open a docs issue.
comment:19 Changed 11 years ago by
Docs issue here: https://github.com/jquery/api.jquery.com/issues/197
jQuery intentionally normalizes all css property values to pixel units