Default input element size

后端 未结 3 1150
醉酒成梦
醉酒成梦 2020-12-18 23:42

The input element by default is size=\"20\" if this is not defined inline or a CSS style rule is attributed to it.

How do you make the default the actual size of the

3条回答
  •  無奈伤痛
    2020-12-19 00:22

    Assuming you have each input on its own row in the form, you can set size attribute to the desired size but also add a css of:

    input[type="text"] {
      max-width: 100%;
    }
    

    This ensures that the field does not overflow the form. This approach gives a visual cue of how much data is expected for short fields (because they will be the right size) while putting a cap on long ones.

提交回复
热议问题