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

前端 未结 14 1845
别那么骄傲
别那么骄傲 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:17

    You could use the CSS3 box-sizing property to include the external padding and border:

    input[type="text"] {
         width: 100%; 
         box-sizing: border-box;
         -webkit-box-sizing:border-box;
         -moz-box-sizing: border-box;
    }
    

提交回复
热议问题