Html 如何在 :focus 上更改 textarea 的边框颜色
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16156594/
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 change border color of textarea on :focus
提问by Mercurial
Forgive me is this is a stupid question, but i need help. I want to change border color of TEXTAREA on focus. but my code doesn't seem to working properly.
原谅我这是一个愚蠢的问题,但我需要帮助。我想在焦点上更改 TEXTAREA 的边框颜色。但我的代码似乎无法正常工作。
Kindly view code on fiddle.
请查看fiddle 上的代码。
<form name = "myform" method = "post" action="insert.php" onsubmit="return validateform()" style="width:40%">
<input type="text" placeholder="Enter Name." name="name" maxlength="300" class="input">
<input type="email" placeholder="Enter E-mail." name="address" maxlength="300" class="input">
<textarea placeholder="Enter Message." name="descrip" class="input" ></textarea>
<br>
<input class="button secondary" type=submit name="submit" value="Submit" >
</form>
Here is the CSS
这是CSS
.input {
border:0;
padding:10px;
font-size:1.3em;
font-family:"Ubuntu Light","Ubuntu","Ubuntu Mono","Segoe Print","Segoe UI";
color:#ccc;
border:solid 1px #ccc;
margin:0 0 20px;
width:300px;
-moz-box-shadow: inset 0 0 4px rgba(0,0,0,0.2);
-webkit-box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.2);
box-shadow: inner 0 0 4px rgba(0, 0, 0, 0.2);
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}
input:focus {
outline: none !important;
border-color: #719ECE;
box-shadow: 0 0 10px #719ECE;
}
回答by adrift
.input:focus {
outline: none !important;
border:1px solid red;
box-shadow: 0 0 10px #719ECE;
}
回答by Philip Sumesgutner
There is an input:focus as there is a textarea:focus
有一个 input:focus 因为有一个 textarea:focus
input:focus {
outline: none !important;
border-color: #719ECE;
box-shadow: 0 0 10px #719ECE;
}
textarea:focus {
outline: none !important;
border-color: #719ECE;
box-shadow: 0 0 10px #719ECE;
}
回答by Grgur
Probably a more appropriate way of changingoutline color is using the outline-color
CSS rule.
可能更合适的更改轮廓颜色的方法是使用outline-color
CSS 规则。
textarea {
outline-color: #719ECE;
}
or for input
或输入
input {
outline-color: #719ECE;
}
box-shadow
isn't quite the same thing and it may look different than the outline, especially if you apply custom styling to your element.
box-shadow
不是完全一样的东西,它看起来可能与轮廓不同,尤其是当您将自定义样式应用于元素时。
回答by Farbod Aprin
so simple :
很简单 :
outline-color : blue !important;
the whole CSS for my react-boostrap button is:
我的 react-boostrap 按钮的整个 CSS 是:
.custom-btn { font-size:1.9em; background: #2f5bff; border: 2px solid #78e4ff; border-radius: 3px; padding: 50px 70px; outline-color : blue !important; text-transform: uppercase; user-select: auto; -moz-box-shadow: inset 0 0 4px rgba(0,0,0,0.2); -webkit-box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.2); -webkit-border-radius: 3px; -moz-border-radius: 3px; }
.custom-btn { font-size:1.9em; background: #2f5bff; border: 2px solid #78e4ff; border-radius: 3px; padding: 50px 70px; outline-color : blue !important; text-transform: uppercase; user-select: auto; -moz-box-shadow: inset 0 0 4px rgba(0,0,0,0.2); -webkit-box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.2); -webkit-border-radius: 3px; -moz-border-radius: 3px; }
回答by Vahid Alvandi
you need just in scss varible
你只需要在 scss 变量中
$input-btn-focus-width: .05rem !default;