How to get equal width of input and select fields

后端 未结 4 2026
梦谈多话
梦谈多话 2020-11-30 18:03

On the form, I have one select and two input fields. These elements are vertically aligned. Unfortunately, I can\'t get equal width of these elements.

Here\'s my co

相关标签:
4条回答
  • 2020-11-30 18:15

    I tried Gaby's answer (+1) above but it only partially solved my problem. Instead I used the following CSS, where content-box was changed to border-box:

    input, select {
        -webkit-box-sizing: border-box;
           -moz-box-sizing: border-box;
                box-sizing: border-box;
    }
    
    0 讨论(0)
  • 2020-11-30 18:16

    Add this code in css:

     select, input[type="text"]{
          width:100%;
          box-sizing:border-box;
        }
    
    0 讨论(0)
  • 2020-11-30 18:17

    Updated answer

    Here is how to change the box model used by the input/textarea/select elements so that they all behave the same way. You need to use the box-sizing property which is implemented with a prefix for each browser

    -ms-box-sizing:content-box;
    -moz-box-sizing:content-box;
    -webkit-box-sizing:content-box; 
    box-sizing:content-box;
    

    This means that the 2px difference we mentioned earlier does not exist..

    example at http://www.jsfiddle.net/gaby/WaxTS/5/

    note: On IE it works from version 8 and upwards..


    Original

    if you reset their borders then the select element will always be 2 pixels less than the input elements..

    example: http://www.jsfiddle.net/gaby/WaxTS/2/

    0 讨论(0)
  • 2020-11-30 18:33

    create another class and increase the with size with 2px example

    .enquiry_fld_normal{
    width:278px !important; 
    }
    
    .enquiry_fld_normal_select{
    width:280px !important; 
     }
    
    0 讨论(0)
提交回复
热议问题