【发布时间】:2021-09-09 15:07:57
【问题描述】:
我要做的是在输入字段聚焦时更改标签字体颜色和边框颜色。有没有办法在不使用 JavaScript 的情况下实现这一点?
.input-label {
display: flex;
align-items: center;
height: 16px;
font-weight: 700;
font-size: 11px;
letter-spacing: .1px;
color: #989898;
text-transform: uppercase;
}
.form-control{
display: inline-block;
max-width: 100%;
word-wrap: normal;
background: transparent;
border: none;
border-bottom: 2px solid #cacaca;
color: #4a4a4a;
font-size: 1.19em;
height: 35px;
letter-spacing: .2px;
padding: 7px 0;
width: 100%;
resize: none;
}
input:focus{
/* after the input is focused the labele font color and border color change to something else*/
}
<div class="firstname">
<label for="name" class="input-label" id="name-label">First Name</label>
<input type="text" class="form-control" id="name" placeholder="First Name" required>
</div>
【问题讨论】: