Skip to main content

Bug Tracker

Side navigation

#12083 closed bug (cantfix)

Opened July 15, 2012 01:39AM UTC

Closed July 17, 2012 09:38PM UTC

Last modified November 27, 2012 05:44PM UTC

Chrome v20 Ignores Units When Setting Width

Reported by: anonymous Owned by: mikesherov
Priority: low Milestone: None
Component: css Version: 1.7.1
Keywords: Cc:
Blocked by: Blocking:
Description

Chrome v20.0.1132.57 m (good lord) ignores units when setting the width of a div.

Steps to repeat:

var scopeTest = jQuery('<div style="padding:0; border:0; width:10000em" </div>').appendTo($(document));
alert(scopeTest.css('width'));
alert(scopeTest.width());

In Chrome I get back "10000px" and "10000". In Firefox I get better values back: "160000px" and "160000" (assuming 10000em equals 160000px in the font). IE8 also returns the right numbers.

(jQuery 1.7.2 seems to return the right number and units for the first call -- "10000em" -- but still gets the second call wrong.)

Attachments (0)
Change History (4)

Changed July 15, 2012 01:41AM UTC by Chris Rywalt <crywalt@westnet.com> comment:1

Sorry, I'm old. Here's a jsFiddle:

http://jsfiddle.net/jAVHY/

Changed July 16, 2012 04:13PM UTC by mikesherov comment:2

component: unfiledcss
milestone: None1.9
owner: → mikesherov
priority: undecidedlow
status: newassigned

Changed July 17, 2012 09:38PM UTC by mikesherov comment:3

resolution: → cantfix
status: assignedclosed

This works as well as we can get it in 1.7.2 and 1.8b2.

Chrome v20 doesn't auto convert between ems and pixels. This can be intepreted as correct behavior according to the W3C specs... they don't really agree on whether pixels should always be returned when another absolute value ( like ems ). I'll open a ticket with Webkit to try to address this, but as you saw, we return the right values for .css('width'), use that.

Thanks for the report!

Changed November 27, 2012 05:44PM UTC by dmethvin comment:4

milestone: 1.9None