Is there a simple way to make html textarea and input type text equally wide?

前端 未结 12 2733
萌比男神i
萌比男神i 2021-02-18 19:29

Is there a simple way of getting a HTML textarea and an input type=\"text\" to render with (approximately) equal width (in pixels), that works in different browsers?

A C

12条回答
  •  迷失自我
    2021-02-18 20:11

    This is a CSS question: the width includes the border and padding widths, which have different defaults for INPUT and TEXTAREA in different browsers, so make those the same as well:

    
    
    
    width
    
    
    
    


    This is described in the Box dimensions section of the CSS specification, which says:

    The box width is given by the sum of the left and right margins, border, and padding, and the content width.

提交回复
热议问题