本文实例为大家分享了JS实现星星海特效的具体代码,供大家参考,具体内容如下
知识点
1.CSS使用@keyframes自定义动画,使用animation调用自定义动画
2.opacity 透明度。从 0.0 (完全透明)到 1.0(完全不透明)
3.CSS中transform
4.animation-delay 属性定义动画何时开始。
5.求屏幕尺寸
var 宽 = document.documentElement.clientWidth; var 高 = document.documentElement.clientHeight;
6.JS创建节点
7.JS在某元素后追加节点
appendChild()
8.UnderScore.js通过_调用其中的API
运行效果
代码
Title *{margin: 0;padding-top: 0} body{background-color: #000} span{ width: 30px; height: 30px; background: url("star.png") no-repeat; position: absolute; background-size: contain; animation: flash 1s alternate infinite; } @keyframes flash{ 0%{opacity: 0} 25%{opacity: 0.25} 50%{opacity: 0.5} 75%{opacity: 0.75} 100%{opacity: 1} } span:hover{ transform: scale(3, 3) rotate(180deg) !important; transition: all 1s; }
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持考高分网。



