【发布时间】:2016-09-22 01:54:09
【问题描述】:
这是我的代码,我试图在输入框聚焦时使标签浮动,这类似于角度材质动画。我的逻辑成功了,但动画似乎不起作用。
我使用的是纯 CSS 和 HTML。
.space {
padding: 5px;
margin-top: 30px;
}
.space .form_input {
display: inline-block;
}
.space .form_input input {
border: none;
border-bottom: solid thin #d6d6d6;
background: none;
position: absolute;
box-shadow: initial;
}
.space .form_input input:focus {
border: none;
border-bottom: solid thin #d6d6d6;
outline: none;
}
.space .form_input input:focus + label {
transition: all 0.7s ease-out;
top: -20px;
}
.space .form_input input:valid + label {
top: -20px;
}
.space .form_input input[value=""] + label {
border: green;
}
.space .form_input input ~ label {
-webkit-transition: all 0.7s ease-out;
-moz-transition: all 0.7s ease-out;
-ms-transition: all 0.7s ease-out;
-o-transition: all 0.7s ease-out;
transition: all 0.7s ease-out;
pointer-events: none;
color: red;
position: relative;
}
<form class='space'>
<div class='form_input'>
<input name='email' id='email' required>
<label for='email'> Email: </label>
</div>
</form>
【问题讨论】:
标签: html css animation css-transitions