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

前端 未结 14 1812
别那么骄傲
别那么骄傲 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 20:54

    I usually set the width of my inputs to 99% to fix this:

    input {
        width: 99%;
    }
    

    You can also remove the default styles, but that will make it less obvious that it is a text box. However, I will show the code for that anyway:

    input {
        width: 100%;
        border-width: 0;
        margin: 0;
        padding: 0;
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
    }
    

    Ad@m

提交回复
热议问题