Html 如何禁用 textarea 调整大小?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9382245/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to disable textarea resizing?
提问by Mo.
I need to disable textarea horizontal resize. Sometimes I want to allow vertical resize on the textarea.
我需要禁用 textarea 水平调整大小。有时我想允许在 textarea 上垂直调整大小。
Whenever I create a contact us page the textarea is making my design ugly.
每当我创建联系我们页面时,textarea 都会使我的设计变得丑陋。
could any one give me a solution to disable it please?
任何人都可以给我一个解决方案来禁用它吗?
回答by Mo.
You can use css
你可以使用 css
disable all
禁用所有
textarea { resize: none; }
only vertical resize
仅垂直调整大小
textarea { resize: vertical; }
only horizontal resize
仅水平调整大小
textarea { resize: horizontal; }
disable vertical and horizontal with limit
禁用垂直和水平限制
textarea { resize: horizontal; max-width: 400px; min-width: 200px; }
disable horizontal and vertical with limit
禁用水平和垂直限制
textarea { resize: vertical; max-height: 300px; min-height: 200px; }
I think min-height
should be useful for you
我认为min-height
应该对你有用
回答by Marc
With some css like this
像这样的一些css
textarea
{
resize: none;
}
Or if you want only vertical
或者如果你只想要垂直
textarea { resize:vertical; }
Or horizontal
或水平
textarea { resize:horizontal; }
or both ( not your case)
或两者兼而有之(不是你的情况)
textarea { resize:both; }
回答by Stelian Matei
You can put this in the CSS file:
你可以把它放在 CSS 文件中:
textarea {
resize: none;
}
回答by Backslash
disable horizontal
and vertical
with limit
禁用horizontal
和vertical
限制
textarea {
width:100%;
resize:vertical;
max-height:250px;
min-height:100px;
}
回答by AmerllicA
For textarea
I used width: 500px !important
and height: 350px !important
, so this CSS
codes prevent user resize, but if you have other tags you must use resize: none
, for complete explanations read This Link.
对于textarea
我使用width: 500px !important
and height: 350px !important
,因此此CSS
代码可防止用户调整大小,但如果您有其他标签,则必须使用resize: none
,有关完整说明,请阅读此链接。
For example, for a p
tag you must set overflow
property with a value that is not visible
and then set resize
, none
, both
, vertical
, horizontal
.
例如,对于p
标签,您必须overflow
使用一个值设置属性,visible
然后设置resize
, none
, both
, vertical
, horizontal
。