[英]Textarea max-width
I'm having problem with textarea max-width, I need it to not exceed .table-cell.two width when resized, on this example: 我有textarea max-width的问题,我需要它在调整大小时不超过.table-cell.two宽度,在这个例子中:
HTML: HTML:
<div class="wrapper">
<div class="table">
<div class="table-cell one">
<p>small cell</p>
</div>
<div class="table-cell two">
<p>textarea cell</p>
<textarea></textarea>
</div>
</div>
CSS: CSS:
textarea {
max-width: 100%;
}
.wrapper {
width: 500px;
}
.table {
display: block;
width: 100%;
}
.table-cell {
display: table-cell;
background: #E2D8C1;
vertical-align: top;
padding: 10px;
}
.table-cell.two {
width: 100%;
background: #DAC082;
}
.table textarea {
max-width: 100%;
width: 100%;
height: 100px
}
Please do not advise using javascript, needed a pure css solution. 请不要建议使用javascript,需要一个纯粹的CSS解决方案。
Use: 采用:
textarea {
/* will prevent resizing horizontally */
resize:vertical;
}
I have this problem too. 我也有这个问题。 The solution is very simple but i spend few hours for experiments... Use this two parameters at the same time in textarea element class/#element style definition (90% 30% are example values) :
解决方案非常简单,但我花了几个小时进行实验...在textarea元素类/#元素样式定义中同时使用这两个参数(90%30%是示例值):
.textarea {
width:90%;
max-width:90%;
max-height:30%;
}
For default the text area is re sizable. 默认情况下,文本区域可以调整大小。 If you want to increase the element width, you can do it by
如果你想增加元素宽度,你可以通过
<textarea rows="4" cols="50">Content here</textarea>
max-width: 300px;
max-height:300px
In your case you want to fix the <textarea>
size when the parent does not have a fixed size. 在您的情况下,您希望在父级没有固定大小时修复
<textarea>
大小。
For textarea you can set 对于textarea你可以设置
<textarea rows="5"></textarea>
and in css 并在css
textarea { height: auto; }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.