HTML input textbox with a width of 100% overflows table cells

前端 未结 14 1528
别那么骄傲
别那么骄傲 2021-01-29 20:28

Does anyone know why the input elements with a width of 100% go over the table\'s cells border.

In the simple example below input box go over the table\'s cells border,

14条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-29 21:03

    I know that this question is 3 years old but the problem still persists for current browsers and folks are still coming here. The solution for now is calc():

    input {
        width: calc(100% - 12px); /* IE 9,10 , Chrome, Firefox */
        width: -webkit-calc(100% - 12px); /*For safari 6.0*/
    }
    

    It is supported by most modern browsers.

提交回复
热议问题