博客
关于我
css3动画-animation
阅读量:488 次
发布时间:2019-03-07

本文共 2006 字,大约阅读时间需要 6 分钟。

CSS3动画实例与技巧

在前端开发中,CSS3动画不仅能够提升用户体验,还能为界面增添趣味性。本文将分享多个实用的CSS动画案例,包括loading动画、骨架屏、纸牌翻转、滚动列表、开始游戏动画以及进度条等。

Loading动画

在数据加载过程中,显示loading动画可以提升用户体验。通过CSS3的animation属性,可以轻松实现不同类型的loading效果。

.loading-1 {
width: 35px;
height: 35px;
position: relative;
}
@-webkit-keyframes loading-1 {
0% {
transform: rotate(0);
}
50% {
transform: rotate(180deg);
}
100% {
transform: rotate(360deg);
}
}
.loading-1 i {
display: block;
width: 100%;
height: 100%;
border-radius: 50%;
background: linear-gradient(transparent 0, transparent 70%, #333 30%, #333 100%);
-webkit-animation: loading-1 0.6s linear 0s infinite;
}

骨架屏

骨架屏是一种优雅的加载效果,可以在数据完全加载前显示页面布局,减少白屏时间。

.skeleton {
height: 6rem;
box-sizing: border-box;
position: relative;
animation-duration: 1s;
animation-fill-mode: forwards;
animation-iteration-count: infinite;
animation-name: placeHolderShimmer;
animation-timing-function: linear;
background: linear-gradient(to right, #eeeeee, #dddddd 10%, #eeeeee 30%);
background-size: 400% 400%;
}

纸牌翻转

通过CSS3的transformanimation,可以实现纸牌翻转的抽奖效果。

.viewport-flip {
-webkit-perspective: 1000;
perspective: 1000;
position: absolute;
}
.flip {
backface-visibility: hidden;
transform: translateX(0);
}
.flip.out {
transform: rotateY(-90deg) scale(0.9);
animation-name: flipouttoleft;
animation-duration: 175ms;
}
.flip.in {
animation-name: flipintoright;
animation-duration: 225ms;
}

滚动列表

通过CSS3动画,可以实现无限滚动的效果。

.roll ul {
list-style: none;
animation: rollList 5s linear infinite;
}

开始游戏动画

使用CSS3动画可以实现流畅的开始游戏效果,避免依赖Flash技术。

.start:hover span {
animation: linear 1.6s infinite;
}

进度条

通过CSS3动画,可以轻松实现多种进度条效果,支持延迟和暂停功能。

div {
height: 10px;
border: 1px solid;
background: linear-gradient(rgb(0, 255, 157), #0ff);
background-repeat: no-repeat;
background-size: 0;
animation: move 2s linear forwards;
}

这些CSS3动画案例可以根据项目需求进行定制和扩展,帮助开发者提升用户体验。

转载地址:http://qjncz.baihongyu.com/

你可能感兴趣的文章
Objective-C实现perfect number完全数算法(附完整源码)
查看>>
Objective-C实现perfect square完全平方数算法(附完整源码)
查看>>
Objective-C实现permutate Without Repetitions无重复排列算法(附完整源码)
查看>>
Objective-C实现pigeon sort鸽巢算法(附完整源码)
查看>>
Objective-C实现PNG图片格式转换BMP图片格式(附完整源码)
查看>>
Objective-C实现pollard rho大数分解算法(附完整源码)
查看>>
Objective-C实现Polynomials多项式算法 (附完整源码)
查看>>
Objective-C实现pooling functions池化函数算法(附完整源码)
查看>>
Objective-C实现porta密码算法(附完整源码)
查看>>
Objective-C实现Pow Logarithmic幂函数与对数函数算法 (附完整源码)
查看>>
Objective-C实现power iteration幂迭代算法(附完整源码)
查看>>
Objective-C实现powLinear函数和powFaster函数算法 (附完整源码)
查看>>
Objective-C实现pow函数功能(附完整源码)
查看>>
Objective-C实现prefix conversions string前缀转换字符串算法(附完整源码)
查看>>
Objective-C实现prefix conversions前缀转换算法(附完整源码)
查看>>
Objective-C实现pressure conversions压力转换算法(附完整源码)
查看>>
Objective-C实现Prim 算法生成图的最小生成树MST算法(附完整源码)
查看>>
Objective-C实现prime sieve eratosthenes埃拉托斯特尼素数筛选法算法(附完整源码)
查看>>
Objective-C实现PrimeCheck函数算法 (附完整源码)
查看>>
Objective-C实现PrimeFactors质因子分解算法 (附完整源码)
查看>>