[英]Changing textarea's border color onselect
Is there an onselect for textarea in css? CSS中是否有onselect用于textarea的? I'm trying to change the border color of the textarea to red onselect instead of the default blue.
我正在尝试将文本区域的边框颜色更改为红色onselect,而不是默认的蓝色。 How would I do that, in css, or html, if that's possible?
如果可能的话,我将如何在CSS或HTML中做到这一点? If not, any other method's fine too.
如果没有,也可以使用其他任何方法。
textarea { resize: none; border-radius: 5px; }
<textarea rows = '4' cols = '50' placeholder = 'Add a new comment...'></textarea>
You can use focus
and border
to change the border color. 您可以使用
focus
和border
更改边框颜色。 Don't forget to set outline: none
as well. 不要忘记设定
outline: none
。
textarea:focus {
resize: none;
border-radius: 5px;
outline: none !important;
border:1px solid red;
}
http://fiddle.jshell.net/tv4zwpn0/ http://fiddle.jshell.net/tv4zwpn0/
Use the :focus selector and disable any outline with outline: none;
使用:focus选择器并禁用带有
outline: none;
任何outline: none;
*:focus { outline: none; } textarea { resize: none; border-radius: 5px; } textarea:focus { border-color: hotpink; }
<textarea rows = '4' cols = '50' placeholder = 'Add a new comment...'></textarea>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.