我试图制作一个 div 动画onmouseover
,但它不起作用
这是我.style.animation
用于 Internet Explorer 和 Firefox 以及.style.webkitanimation
chrome 的 javascript:
function emailhelp() {
document.getElementById('help-text').innerHTML = 'Enter you´re email';
document.getElementById('help-box').style.animation ='myfirst 5s;';
document.getElementById('help-box').style.webkitanimation ='myfirst 5s;';
}
这是CSS:
@keyframes myfirst
{
from {background-color:#00304c;}
to {background-color:yellow;}
}
@-webkit-keyframes myfirst /* Safari and Chrome */
{
from {background-color:#00304c;}
to {background-color:yellow;}
}
#help-box {
position: fixed;
top: 82px;
left: 50%;
margin-left: 289px;
font-size: 12px;
background-color: #00304c;
height: 32px;
width: 250px;
line-height: 32px;
padding-left: 10px;
margin-right: 0px;
text-align:center;
}
这是我的 HTML:
<input class="user-input" name="" type="text" value="email" onmouseover="emailhelp()" onmouseout="helphide()" onfocus="if(this.value == 'email') { this.value = ''; }" onblur="if(this.value == '') { this.value = 'email'; }" onmouseover="emailhelp()" onmouseout="helphide()" />