开发者

I have a textarea that won't have 100% in width when I set it in CSS or plain HTML?

How can I set a textarea to 100% in width? 开发者_运维问答it dosn't work when I say: textarea {width: 100%} in css.


There are several ways to fix this issue:

  • Give the parent element a padding-right equal to the accumulated border-width and padding of the textarea (supported by all browsers)
  • Use the box-sizing property to include border and padding when setting width:

    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    

    (supported by IE8+ and all other browsers)


It does work but a parent element is probably just restricting the width of your <textarea> so without seeing your code there's no specific answer to your question.


Make sure all of the parent elements have an appropriate width - post more information if that doesn't help.


You are forgetting a semi-column:

textarea {
    width: 100%;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜