How can I add padding to a textarea without causing the width to increase?

后端 未结 4 1407
谎友^
谎友^ 2021-02-05 06:58

I\'ve been having trouble setting a textarea element\'s width and using padding via CSS. The padding value seems to change the width of the textarea, which I\'d rather it not do

4条回答
  •  轮回少年
    2021-02-05 07:05

    The width specified by CSS does not include padding or border (in accordance with W3C specifications). I guess one way of doing it is with some JavaScript that sets the width of #editor to the width of #body minus 700px, but that's a bit messy... Not sure if there's a CSS way of doing what you want here. Of course, you could use margin then register the onMouseWheel event to the #body and work with that...

提交回复
热议问题