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

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

    Specifying widths and margins/padding in '%' helps. Here is one example -

    Live @ http://jsfiddle.net/ninadpachpute/V2aaa/embedded/result

    #body {
      background-color:#ccc;
      height:100%;
      width:100%;
      display:block;
    }
    
    textarea#editor {
      border:none;
      width:80%;
      height:100%;
      margin-left:10%;
      margin-right:10%;
    }
    

提交回复
热议问题