How can I make a TextArea 100% width without overflowing when padding is present in CSS?

前端 未结 15 2148
失恋的感觉
失恋的感觉 2020-11-29 14:44

I have the following CSS and HTML snippet being rendered.

<
15条回答
  •  醉梦人生
    2020-11-29 14:47

    The answer to many CSS formatting problems seems to be "add another

    !"

    So, in that spirit, have you tried adding a wrapper div to which the border/padding are applied and then putting the 100% width textarea inside of that? Something like (untested):

    textarea
    {
      width:100%;
    }
    .textwrapper
    {
      border:1px solid #999999;
      margin:5px 0;
      padding:3px;
    }