0

Why is it that <input> and <select> fields are displayed in different sizes, even if formatted in the same way?

.classname fieldset input,select {
  float: right;
  width: 50%;
}

The <select> ends up a little smaller than <input>. - Here's a fiddle. enter image description here

3
  • What browser, version, os, device? Commented Jun 3, 2015 at 6:46
  • add - box-sizing: border-box; for .classname fieldset input,select Commented Jun 3, 2015 at 6:48
  • FF 38.0.1 , IE 11.0.9600.17801 , Chrome is working fine. Commented Jun 3, 2015 at 6:53

2 Answers 2

1

Try specifying box-sizing and reseting border values:

.classname fieldset input,select 
{
    float: right;
    width: 50%;
    -ms-box-sizing: content-box;
    -moz-box-sizing: content-box;
    -webkit-box-sizing: content-box;
    box-sizing: content-box;
    border: 1px solid #AAA; /* Set your color here. */
}
Sign up to request clarification or add additional context in comments.

2 Comments

Strange, this helped a little but didn't solve the problem. Still one px difference.
Added padding: 1px; in additional to your code was the solution.
0

As noted, you likely want to set box-sizing, however it should be set to border-box and not content-box, meaning you should also not need to change anything else:

.classname fieldset input,select {
  float: right;
  width: 50%;
  box-sizing:border-box;
}

Box-Sizing:

The box-sizing CSS property is used to alter the default CSS box model used to calculate widths and heights of elements.

border-box

The width and height properties include the padding and border, but not the margin.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.