我想知道是否有人可以帮助我在两秒后将 div 的颜色从黑色更改为白色,然后在两秒后从白色更改为黑色,然后再更改回来等等,只要 div 存在即可。换句话说,div 仅在用户单击并拖动表面(就像桌面选择区域)时显示,我的目标是如上所述更改边框的颜色,同时用户仍在进行选择surface 就像调整 div 的大小一样。
最佳答案
如果您的浏览器要求允许您使用 css3,那么您根本不需要任何 javascript。
HTML:
<div class="blinkdiv">
</div>
CSS:
@-webkit-keyframes blackWhite {
0% { background-color: white; }
50% { background-color: white; }
51% { background-color: black; }
100% { background-color: black; }
}
.blinkdiv {
height: 100px;
background-color: black;
-webkit-animation-name: blackWhite;
-webkit-animation-iteration-count: infinite;
-webkit-animation-duration: 2s;
}
关于javascript - 随着时间的推移来回改变颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18582555/