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

后端 未结 4 1356
谎友^
谎友^ 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:04

    Some browsers allow you to target the placeholder for changing the color etc., so you can add padding as well:

    ::-webkit-input-placeholder { /* WebKit browsers */
        padding: 5px 0 0 5px;
    }
    :-moz-placeholder { /* Mozilla Firefox 4 to 18 */
        padding: 5px 0 0 5px;
    }
    ::-moz-placeholder { /* Mozilla Firefox 19+ */
        padding: 5px 0 0 5px;
    }
    :-ms-input-placeholder { /* Internet Explorer 10+ */
        padding: 5px 0 0 5px;
    }
    

提交回复
热议问题