CSS3实现页面图案飘落动画
2018-02-23 18:50
489 查看
css3实现的动画,仅供参考,效果还是不错的哦!
<!DOCTYPE html>
<html>
<head>
<title>css3实现飘落动画</title>
<meta charset="utf-8">
<script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.1.1/jquery.min.js"></script>
<style type="text/css">
body{
margin: 0px;
padding: 0px;
}
.page{
width: 100vw;
height: 100vh;
background: url('http://pic.90sjimg.com/back_pic/u/00/28/77/06/56162d121fdcf.jpg') no-repeat;
background-size:cover;
}
.test{
}
.test1{
position: absolute;
color: transparent;
-webkit-background-clip: text;
background-clip: text;/*背景只显示有文字的地方*/
}/*
@keyframes test{
100%{
opacity: 0.4
}
}
@-webkit-keyframes test{
100%{
opacity: 0.4
}
}
.animated{
animation: 'test' 5s linear forwards;
-webkit-animation: 'test' 5s linear both;
}*/
</style>
<script type="text/javascript">
$(function(){
setInterval(function(){
var content = ['✿','♫','❤','✪'];//文字图案数组
var test = $('<div class="test1"></div>').text(content[parseInt(Math.random()*7)]);
var pageWidth = $('.page').width();//页面宽度
var x = Math.random()*(pageWidth)-100;//开始横向位置
var deg = Math.random()*360;//开始旋转角度
var size = 25 + Math.random()*30;//文字图案的大小
var duration = 5 + Math.random()*2;//transition动画执行时间
var colorArray =['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'];
var beginColor = '#';//背景渐变开始颜色
var endColor = '#';//背景渐变结束颜色
var endPositionX = parseInt(Math.random()*100+50);//结束位置的横向位置
var endHeight = document.documentElement.clientHeight - 65 - parseInt(Math.random()*40);//结束高度
for(var i =0; i<6; i++){
beginColor+=colorArray[parseInt(Math.random()*15)];
endColor+=colorArray[parseInt(Math.random()*15)];
}
test.appendTo('.page')
.css({
transform:'translate3d('+ x +'px,-100px,0)' + 'rotateZ('+ deg +'deg)',
'font-size':size + 'px',
'background-image':'-webkit-linear-gradient('+beginColor+','+endColor+')',//渐变背景
});
setTimeout(function(){
test.css({
transition:'all '+ duration +'s linear',
opacity:'0.4',
transform:"translate3d("+ endPositionX +"px,"+endHeight+"px,0) rotateZ(360deg)",
});
},100);//延迟0.1秒是因为js执行过快把后面的transform覆盖前面的transform,造成效果丢失
setTimeout(function(){
test.remove();
},duration*1000);
},1000);
});
</script>
</head>
<body>
<div class="page">
<div class="test">
<audio src="http://dl.stream.qqmusic.qq.com/C400002R32LQ2u9c4z.m4a?vkey=694477E98A99B2D95AEB444C98A94C0ADE92691376297496CED3C04AF48A67C44E26746E3F259AA9AB3DC20769F957BA42544460523D4459&guid=9645588772&uin=0&fromtag=66" autoplay loop>
您的浏览器不支持 audio 标签。
</audio>
</div>
</div>
</body&
4000
gt;
</html>
<!DOCTYPE html>
<html>
<head>
<title>css3实现飘落动画</title>
<meta charset="utf-8">
<script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.1.1/jquery.min.js"></script>
<style type="text/css">
body{
margin: 0px;
padding: 0px;
}
.page{
width: 100vw;
height: 100vh;
background: url('http://pic.90sjimg.com/back_pic/u/00/28/77/06/56162d121fdcf.jpg') no-repeat;
background-size:cover;
}
.test{
}
.test1{
position: absolute;
color: transparent;
-webkit-background-clip: text;
background-clip: text;/*背景只显示有文字的地方*/
}/*
@keyframes test{
100%{
opacity: 0.4
}
}
@-webkit-keyframes test{
100%{
opacity: 0.4
}
}
.animated{
animation: 'test' 5s linear forwards;
-webkit-animation: 'test' 5s linear both;
}*/
</style>
<script type="text/javascript">
$(function(){
setInterval(function(){
var content = ['✿','♫','❤','✪'];//文字图案数组
var test = $('<div class="test1"></div>').text(content[parseInt(Math.random()*7)]);
var pageWidth = $('.page').width();//页面宽度
var x = Math.random()*(pageWidth)-100;//开始横向位置
var deg = Math.random()*360;//开始旋转角度
var size = 25 + Math.random()*30;//文字图案的大小
var duration = 5 + Math.random()*2;//transition动画执行时间
var colorArray =['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'];
var beginColor = '#';//背景渐变开始颜色
var endColor = '#';//背景渐变结束颜色
var endPositionX = parseInt(Math.random()*100+50);//结束位置的横向位置
var endHeight = document.documentElement.clientHeight - 65 - parseInt(Math.random()*40);//结束高度
for(var i =0; i<6; i++){
beginColor+=colorArray[parseInt(Math.random()*15)];
endColor+=colorArray[parseInt(Math.random()*15)];
}
test.appendTo('.page')
.css({
transform:'translate3d('+ x +'px,-100px,0)' + 'rotateZ('+ deg +'deg)',
'font-size':size + 'px',
'background-image':'-webkit-linear-gradient('+beginColor+','+endColor+')',//渐变背景
});
setTimeout(function(){
test.css({
transition:'all '+ duration +'s linear',
opacity:'0.4',
transform:"translate3d("+ endPositionX +"px,"+endHeight+"px,0) rotateZ(360deg)",
});
},100);//延迟0.1秒是因为js执行过快把后面的transform覆盖前面的transform,造成效果丢失
setTimeout(function(){
test.remove();
},duration*1000);
},1000);
});
</script>
</head>
<body>
<div class="page">
<div class="test">
<audio src="http://dl.stream.qqmusic.qq.com/C400002R32LQ2u9c4z.m4a?vkey=694477E98A99B2D95AEB444C98A94C0ADE92691376297496CED3C04AF48A67C44E26746E3F259AA9AB3DC20769F957BA42544460523D4459&guid=9645588772&uin=0&fromtag=66" autoplay loop>
您的浏览器不支持 audio 标签。
</audio>
</div>
</div>
</body&
4000
gt;
</html>
相关文章推荐
- 实现html页面及css3动画
- 前端技术:迅雷7.9宣传下载页面CSS3动画实现心得
- css3简单实现页面中出现雪花飘落效果
- 纯css3实现的鼠标悬停动画按钮
- ios 实现导航控制器带动画的推送页面
- 通过jquery实现页面的动画效果
- jQuery.smoove — jQuery和CSS3炫酷滚动页面内容元素动画特效插件
- CSS3用transition实现边框动画效果
- 使用CSS3实现60FPS动画
- 编写一个项目,实现页面之间切换时的动画效果。上传代码并描述步骤
- css3动画—实现上拉提示指针动画
- 【CSS3】用纯CSS实现加载中动画效果
- 使用CSS3实现加载中动画
- CSS3实现大小不一的粒子旋转加载动画
- 超棒的CSS3动画页面过渡效果
- 一款jquery和css3实现的卡通人物动画特效
- CSS3----实现光芒旋转头像动画
- Android Activity/活动页面切换实现动画效果
- 一款纯css3实现的动画加载导航
- 纯CSS3实现动画不规则的tab标签切换代码