Bug Tracker

Modify

Ticket #10595 (closed bug: invalid)

Opened 19 months ago

Last modified 19 months ago

Selectbox width() and css('width') discrepancies

Reported by: Adam Owned by:
Priority: low Milestone: None
Component: css Version: 1.6.4
Keywords: Cc:
Blocking: Blocked by:

Description

See JS fiddle at:  http://jsfiddle.net/8MW4u/3/

CSS: width: 100px border: 1px padding: 5px

The jQuery width() method incorrectly subtracts the borders width (2px) of a 100px width selectbox in Chrome, reporting the width as 98px instead. This does not happen with an input field of type text with the exact same CSS.

In Firefox the discrepancy is even worse, since there the padding is also subtracted, reporting a width of 88px. Again, for a text input everything works fine.

The exact same problem occurs with css('width'), which reports the same values.

Why are the reported widths of a selectbox not consistent with the reported widths of a text input? And why not cross-browser consistent at least?

Change History

comment:1 Changed 19 months ago by timmywil

  • Priority changed from undecided to low
  • Resolution set to invalid
  • Status changed from new to closed
  • Component changed from unfiled to css

This is due to a combination of the nature of the box model and the different default styles for select boxes and inputs. What you are retrieving is the real and correct _computed_ values, even if they are different across browsers. To unify them, all of the necessary css properties need to match across browsers in order to get the same behaviors.

Something like this:  http://jsfiddle.net/timmywil/8MW4u/6/

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.