Bug Tracker

Opened 12 years ago

Closed 11 years ago

Last modified 11 years ago

#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.

http://jsfiddle.net/kgorsky/Vfmjp/

Change History (19)

comment:1 Changed 12 years ago by Rick Waldron

Component: unfiledcss
Priority: undecidedlow
Resolution: invalid
Status: newclosed

jQuery intentionally normalizes all css property values to pixel units

comment:2 Changed 12 years ago by Rick Waldron

Resolution: invalid
Status: closedreopened

comment:3 Changed 12 years ago by Rick Waldron

Resolution: duplicate
Status: reopenedclosed

comment:4 Changed 12 years ago by Rick Waldron

Duplicate of #9928.

comment:5 in reply to:  1 Changed 12 years ago by kgorsky

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 Rick Waldron

Resolution: duplicate
Status: closedreopened

Thanks for the heads up.

Confirmed, further reduced: http://jsfiddle.net/rwaldron/xTgvF/

comment:7 Changed 12 years ago by Rick Waldron

Status: reopenedopen

comment:8 Changed 12 years ago by Rick Waldron

Milestone: None1.7
Priority: lowhigh

comment:9 Changed 12 years ago by mikesherov

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 mikesherov

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 Timmy Willison

Milestone: 1.71.next
Owner: set to Timmy Willison
Status: openassigned

Per meeting, pushing this until we have time to refactor.

comment:12 Changed 11 years ago by mikesherov

#11944 is a duplicate of this ticket.

comment:13 Changed 11 years ago by anonymous

Hello ! Are you still working on this bug ?

comment:14 Changed 11 years ago by anonymous

We need a solution for this bug, please help us!

comment:15 Changed 11 years ago by Timmy Willison

Owner: Timmy Willison deleted
Status: assignedopen

comment:16 Changed 11 years ago by pbramos

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 mikesherov

Resolution: wontfix
Status: openclosed

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.

Note: See TracTickets for help on using tickets.