Select inputs and text inputs in HTML - Best way to make equal width?

前端 未结 3 899
耶瑟儿~
耶瑟儿~ 2020-11-28 19:05

I\'ve got a simple form like so (illustrative purposes only)...

相关标签:
3条回答
  • 2020-11-28 19:36

    The solution is to specify box model for form elements, and browsers tend to agree most when you use border-box:

    input, select, textarea {
      -webkit-box-sizing: border-box;
         -moz-box-sizing: border-box;
              box-sizing: border-box;
    }
    

    There's normalize.css project that aggregates such tricks.

    0 讨论(0)
  • 2020-11-28 19:39

    padding will make the text be closer to the edge of the box.

    try setting the margin to 0px, and if that seems right, play around with it (like just setting margin-left only)

    0 讨论(0)
  • 2020-11-28 19:46

    Had same problems with 100% width table and cells, with a textbox (also with width at 100%) wider than the table cell.

    This solved my problem in the css:

    table td
    {
        padding-right: 8px;
    }
    

    Not the best solution ever, cause you probably get some additional space to the right side. But at least it's not hiding anymore!

    0 讨论(0)
提交回复
热议问题