gpt4 book ai didi

CSS :focus border transition won't work when a border-bottom is already set

转载 作者:太空宇宙 更新时间:2023-11-04 06:37:20 24 4
gpt4 key购买 nike

我正在设计一个文本输入字段的样式,重点是当它获得焦点时边框和文本会改变颜色。

问题:当我在初始状态下为“border-bottom”设置样式时,过渡不起作用。
我在开发工具中弄乱了一点,当我删除初始边框底部时,过渡效果很好。但我仍然想保留我最初的边框样式,所以我不确定这里发生了什么。

我已经搜索并试验了几天,但没有任何效果或帮助。因此,如果有人知道这个问题,将不胜感激!

.contactInput {
color: #555;
padding: 7px 0;
background-color: rgba(0,0,0,0);
font-style: normal;
font-weight: 400;
line-height: 20px;
font-size: 14px;
border-bottom: 2px solid #555;
outline: none;
transition: all 0.2s ease-in;
}

.contactInput:focus {
color: #000;
font-weight: 600;
border-bottom: 2px solid #000;
transition: all 0.2s ease-in;
}
<form>
<input placeholder="Name" class="contactInput" type="text" name="" id=""/>
<input placeholder="Email" class="contactInput" type="text" name="" id=""/>
</form>

最佳答案

更正焦点中的边框底部。

.contactInput:focus {
border-bottom: 2px solid #000;
}

或者你可以改变边框颜色

.contactInput:focus {
border-bottom-color: #000;
}

希望这能解决你的问题

关于CSS :focus border transition won't work when a border-bottom is already set,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54104681/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com