【发布时间】:2019-06-03 21:44:41
【问题描述】:
我正在设置文本输入字段的样式,重点是边框和文本在获得焦点时会改变颜色。
问题:当我在初始状态下为“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>
【问题讨论】:
-
你也应该添加 HTML 部分
-
你在什么浏览器上测试它??
-
Opera、Chrome、Edge 和 IE
-
还不行吗??
-
还没有,我虽然可能是另一行 css 干扰了它,但我证实事实并非如此
标签: css css-transitions border transition