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

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

I have the following CSS and HTML snippet being rendered.

<
15条回答
  •  渐次进展
    2020-11-29 15:07

    If you pad and offset it like this:

    textarea
    {
        border:1px solid #999999;
        width:100%;
        padding: 7px 0 7px 7px; 
        position:relative; left:-8px; /* 1px border, too */
    }
    

    the right side of the textarea perfectly aligns with the right side of the container, and the text inside the textarea aligns perfectly with the body text in the container... and the left side of the textarea 'sticks out' a bit. it's sometimes prettier.

提交回复
热议问题