【发布时间】:2018-07-12 23:21:55
【问题描述】:
我有一个输入文本框。选择相同的,突出显示(文本框周围的蓝色框)出现。我需要一条红线作为输入文本框选择的底部边框。请看代码:
input:focus {
background-color: yellow;
}
.myclass:focus {
border-bottom: red;
}
<p>Click inside the text fields to see a yellow background:</p>
<form>
First input box: <input class="myclass" type="text" name="firstname"><br>
Second input box: <input type="text" name="lastname">
</form>
由于我的页面中有多个输入文本框,并且我只想将样式应用于一个文本框。所以我不能使用 input:focus 代码。如何将 ':focus' 应用于 css 中的特定类?请帮忙提前谢谢
【问题讨论】:
-
.myclass:focus不起作用? -
你需要设置
outline的样式而不是焦点,但不确定你是否只能做一侧 - 你可能想取消轮廓,然后使用带有 :focus 的border-bottom -
不,我不知道为什么
-
边框宽度给定,如
border:1px soild