CSS100Day(28)-振铃动画
1099 字
5 分钟
CSS100Day(28)-振铃动画
设计简介
关键点如下
- 知识点1:没啥新奇,仅展示成果
效果展示
实现代码和步骤
HTML部分
<div class="frame"> <svg width="14px" height="60px" class="line line-1"> <path d="M2,58 C14,45 14,15 2,2"></path> </svg> <svg width="14px" height="60px" class="line line-2"> <path d="M2,58 C14,45 14,15 2,2"></path> </svg> <svg width="14px" height="60px" class="line line-3"> <path d="M2,58 C14,45 14,15 2,2"></path> </svg> <svg width="14px" height="60px" class="line line-4"> <path d="M12,58 C0,45 0,15 12,2"></path> </svg> <svg width="14px" height="60px" class="line line-5"> <path d="M12,58 C0,45 0,15 12,2"></path> </svg> <svg width="14px" height="60px" class="line line-6"> <path d="M12,58 C0,45 0,15 12,2"></path> </svg> <svg width="50px" height="54px" viewBox="0 0 50 54" class="bell"> <path d="M1.13063517,45.0453694 C1.88439195,45.7991262 2.80138269,46.1760046 3.82399539,46.1760046 L17.2955975,46.1760046 C17.2955975,48.331653 18.0493543,50.110423 19.5592683,51.6179365 C21.0667819,53.1254501 22.8983629,53.8816074 25.0012002,53.8816074 C27.1544481,53.8816074 28.9332181,53.1254501 30.4431322,51.6179365 C31.9506457,50.110423 32.7044025,48.331653 32.7044025,46.1760046 L46.1760046,46.1760046 C47.1986173,46.1760046 48.115608,45.7991262 48.8693648,45.0453694 C49.6231216,44.2892122 50,43.3746219 50,42.3496087 C46.1760046,39.1185367 43.3194104,35.1313073 41.379807,30.3879207 C39.4402036,25.6469346 38.4704018,20.6370925 38.4704018,15.408805 C38.4704018,12.0697105 37.5006001,9.48197225 35.6138077,7.54236881 C33.6742042,5.54995439 31.033655,4.41931922 27.6945605,3.98722934 C27.8553939,3.66316194 27.9106054,3.28628355 27.9106054,2.90940516 C27.9106054,2.10043689 27.639349,1.40189159 27.0488262,0.86177925 C26.5087138,0.268855922 25.807768,0 25.0012002,0 C24.192232,0 23.5464977,0.268855922 23.0063853,0.86177925 C22.413462,1.40189159 22.1446061,2.10043689 22.1446061,2.90940516 C22.1446061,3.28628355 22.1974171,3.66316194 22.360651,3.98722934 C19.019156,4.41931922 16.3786068,5.54995439 14.4390033,7.54236881 C12.4993999,9.48197225 11.5295982,12.0697105 11.5295982,15.408805 C11.5295982,20.6370925 10.5597964,25.6469346 8.620193,30.3879207 C6.68058956,35.1313073 3.82399539,39.1185367 0,42.3496087 C0,43.3746219 0.376878391,44.2892122 1.13063517,45.0453694 L1.13063517,45.0453694 Z M20.2050026,45.6911037 C20.52907,45.6911037 20.6899035,45.8519372 20.6899035,46.1760046 C20.6899035,47.3618513 21.1195929,48.384464 21.9837726,49.1934322 C22.7903404,50.0552115 23.8153536,50.4873014 25.0012002,50.4873014 C25.3228672,50.4873014 25.4861011,50.6481348 25.4861011,50.9722022 C25.4861011,51.2938691 25.3228672,51.4571031 25.0012002,51.4571031 C23.5464977,51.4571031 22.3054395,50.9169907 21.2828268,49.894378 C20.2578136,48.8693648 19.7201018,47.6307072 19.7201018,46.1760046 C19.7201018,45.8519372 19.8809352,45.6911037 20.2050026,45.6911037 L20.2050026,45.6911037 Z" ></path> </svg></div>CSS部分
.frame { width: 400px; height: 400px; position: relative; box-shadow: 1px 2px 10px 0 rgba(0, 0, 0, 0.3); overflow: hidden; background: #dd3c54; border-radius: 2px;}.bell { position: absolute; top: 173px; left: 175px; fill: #fff; transform-origin: 50% 0%; animation: shake 2.5s ease infinite;}.line { fill: none; stroke: #fff; stroke-width: 2px; stroke-linecap: round;}.line-1,.line-2,.line-3 { position: absolute; top: 170px; left: 230px;}.line-4,.line-5,.line-6 { position: absolute; top: 170px; right: 230px;}.line-1 { animation: line-1 2.5s ease-out infinite both;}.line-2 { animation: line-2 2.5s ease-out infinite both;}.line-3 { animation: line-3 2.5s ease-out infinite both;}.line-4 { animation: line-4 2.5s ease-out infinite both;}.line-5 { animation: line-5 2.5s ease-out infinite both;}.line-6 { animation: line-6 2.5s ease-out infinite both;}@keyframes shake { 0%, 50%, 100% { transform: rotate(0deg); } 5%, 10%, 15%, 20%, 25%, 30%, 35%, 40% { transform: rotate(6deg); } 45% { transform: rotate(4deg); } 7.5%, 12.5%, 17.5%, 22.5%, 27.5%, 32.5%, 37.5%, 42.5% { transform: rotate(-6deg); } 47.5% { transform: rotate(-2deg); }}@keyframes line-1 { 0% { transform: translate3d(0, 0, 0) scale(1); opacity: 1; } 50%, 100% { transform: translate3d(60px, 0, 0) scale(2); opacity: 0; }}@keyframes line-2 { 0%, 19% { opacity: 0; } 20% { transform: translate3d(0, 0, 0) scale(1); opacity: 1; } 70%, 100% { transform: translate3d(60px, 0, 0) scale(2); opacity: 0; }}@keyframes line-3 { 0%, 39% { opacity: 0; } 40% { transform: translate3d(0, 0, 0) scale(1); opacity: 1; } 90%, 100% { transform: translate3d(60px, 0, 0) scale(2); opacity: 0; }}@keyframes line-4 { 0% { transform: translate3d(0, 0, 0) scale(1); opacity: 1; } 50%, 100% { transform: translate3d(-60px, 0, 0) scale(2); opacity: 0; }}@keyframes line-5 { 0%, 19% { opacity: 0; } 20% { transform: translate3d(0, 0, 0) scale(1); opacity: 1; } 70%, 100% { transform: translate3d(-60px, 0, 0) scale(2); opacity: 0; }}@keyframes line-6 { 0%, 39% { opacity: 0; } 40% { transform: translate3d(0, 0, 0) scale(1); opacity: 1; } 90%, 100% { transform: translate3d(-60px, 0, 0) scale(2); opacity: 0; }}JS部分
无JS代码
分享给其他人
如果该文章对您有帮助,欢迎分享给其他人阅读!
复制链接
相关文章
推荐筛选
1
CSS100Day(24)-一个按钮动画
设计灵感 依然使用svg-dasharray转圈,使用checkbutton实现点击动画加载
2
CSS100Day(23)-动态字体动画设计
设计灵感 线段的动画设计,以及文字隐藏出现的设计
3
CSS100Day(10)-SVG旋转动画
设计灵感 巧妙应用SVG的
4
CSS100Day(2)-菜单按钮动画
设计灵感 菜单按钮都见过,但是三根条动画实现,关键利用no-animation初始化时候关闭回复动画
5
CSS100Day(25)-翻转动画另一种实现
设计灵感 翻转动画另一种实现
随机文章
随机推荐