Skip to main content

Bug Tracker

Side navigation

#9945 closed bug (wontfix)

Opened August 01, 2011 02:27AM UTC

Closed December 29, 2012 10:46PM UTC

Last modified December 29, 2012 10:49PM UTC

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/

Attachments (0)
Change History (19)

Changed August 01, 2011 02:42AM UTC by rwaldron comment:1

component: unfiledcss
priority: undecidedlow
resolution: → invalid
status: newclosed

jQuery intentionally normalizes all css property values to pixel units

Changed August 01, 2011 02:43AM UTC by rwaldron comment:2

resolution: invalid
status: closedreopened

Changed August 01, 2011 02:43AM UTC by rwaldron comment:3

resolution: → duplicate
status: reopenedclosed

Changed August 01, 2011 02:43AM UTC by rwaldron comment:4

Duplicate of #9928.

Changed August 01, 2011 02:49AM UTC by kgorsky comment:5

Replying to [comment:1 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.

Changed August 01, 2011 03:01AM UTC by rwaldron comment:6

resolution: duplicate
status: closedreopened

Thanks for the heads up.

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

Changed August 01, 2011 03:02AM UTC by rwaldron comment:7

status: reopenedopen

Changed August 01, 2011 03:02AM UTC by rwaldron comment:8

milestone: None1.7
priority: lowhigh

Changed October 14, 2011 11:16PM UTC by mikesherov comment:9

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?

Changed October 18, 2011 03:35AM UTC by mikesherov comment:10

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

Changed October 24, 2011 04:26PM UTC by timmywil comment:11

milestone: 1.71.next
owner: → timmywil
status: openassigned

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

Changed June 21, 2012 03:08PM UTC by mikesherov comment:12

#11944 is a duplicate of this ticket.

Changed October 10, 2012 02:43AM UTC by anonymous comment:13

Hello ! Are you still working on this bug ?

Changed October 21, 2012 11:17PM UTC by anonymous comment:14

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

Changed October 22, 2012 05:38PM UTC by timmywil comment:15

owner: timmywil
status: assignedopen

Changed November 02, 2012 04:12AM UTC by pbramos comment:16

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.

Changed November 08, 2012 04:57AM UTC by pbramos comment:17

Changed December 29, 2012 10:46PM UTC by mikesherov comment:18

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.

Changed December 29, 2012 10:49PM UTC by mikesherov comment:19