CSS100Day(20)-发送邮件惊艳动画无JS
961 字
5 分钟
CSS100Day(20)-发送邮件惊艳动画无JS
设计简介
用精美的动画效果给访客带来惊喜,而不是简单的“请求已发送”提示
-
知识点1:点击发送按钮可以使用
checkbox:checked来执行效果,而不使用javascript点击事件 -
知识点2:前面学过使用
stroke-dasharray,以及stroke-dashoffset对SVG线段做出绘画的感觉
效果展示
实现代码和步骤
HTML部分
HTML部分如下,主要是实现邮件和纸飞机的svg,仅有svg有stroke系列属性
<div class="frame"> <input type="checkbox" id="cb" /> <label for="cb" class="button">发送邮件</label> <label for="cb" class="button reset">重置</label> <div class="circle"></div> <div class="circle-outer"></div> <svg class="icon mail"> <polyline points="119,1 119,69 1,69 1,1"></polyline> <polyline points="119,1 60,45 1,1 119,1"></polyline> </svg> <svg class="icon plane"> <polyline points="119,1 1,59 106,80 119,1"></polyline> <polyline points="119,1 40,67 43,105 69,73"></polyline> </svg></div>CSS部分
.frame { width: 400px; height: 400px; box-shadow: 1px 2px 10px 0 rgba(0, 0, 0, 0.3); border-radius: 2px; background: #2c3e50; overflow: hidden; position: relative;}.circle { position: absolute; background: #354a5f; border-radius: 50%; width: 200px; height: 200px; top: 65px; left: 100px;}.circle-outer { position: absolute; box-sizing: border-box; background: none; border: 4px solid #354a5f; border-radius: 50%; width: 200px; height: 200px; top: 65px; left: 100px;}.icon { position: absolute; z-index: 2; top: 130px; left: 140px; transform: translate3d(0, 0, 0); fill: none; stroke-width: 2px; stroke: #ecf0f1; stroke-linecap: square; stroke-dasharray: 325 325; &.mail { width: 120px; height: 70px; stroke-dashoffset: 0; } &.plane { width: 120px; height: 110px; stroke-dashoffset: 325; }}#cb { display: none;}.button { position: absolute; z-index: 10; top: 290px; left: 100px; background: #ecf0f1; color: #2c3e50; width: 200px; height: 40px; border-radius: 20px; text-align: center; line-height: 40px; cursor: pointer; transition: all 0.3s ease; font-weight: 700; &.reset { opacity: 0; z-index: 5; } &:hover { background: #1abc9c; color: #fff; }}#cb:checked ~ .button { animation: button 1.5s ease-in-out 1.7s; animation-fill-mode: both;}#cb:checked ~ .reset { animation: reset 1s ease-in-out 3.7s; animation-fill-mode: both;}#cb:checked ~ .mail { transition: stroke-dashoffset 1s ease-in-out; stroke-dashoffset: 325;}#cb:checked ~ .plane { transition: stroke-dashoffset 1s ease-in-out 0.6s; stroke-dashoffset: 0; animation: fly 2.4s ease-in-out; animation-fill-mode: both;}#cb:checked ~ .circle { animation: circle 1s ease-in-out; animation-fill-mode: both;}#cb:checked ~ .circle-outer { animation: circle 0.8s ease-in-out 0.2s; animation-fill-mode: both;}@keyframes button { 0% { transform: scale(1); } 30% { background: #1abc9c; color: transparent; width: 200px; left: 100px; } 50%, 60% { width: 40px; left: 180px; transform: scale(1); } 70% { transform: scale(1.1); } 100% { width: 40px; left: 180px; background: #1abc9c; color: transparent; transform: scale(0); }}@keyframes reset { from { opacity: 0; } to { opacity: 1; }}@keyframes fly { 0%, 50% { transform: translate3d(0, 0, 0) scale(1); } 60% { transform: translate3d(-10px, 5px, 0) scale(1.05); } 70% { opacity: 1; } 85% { opacity: 0; } 100% { transform: translate3d(300px, -150px, 0) scale(0.5); opacity: 0; }}@keyframes circle { 0% { transform: translate3d(0, 0, 0) scale(1); } 20% { transform: scale(1.1); } 100% { transform: scale(0); }}分享给其他人
如果该文章对您有帮助,欢迎分享给其他人阅读!
复制链接
相关文章
推荐筛选
1
CSS100Day(10)-SVG旋转动画
设计灵感 巧妙应用SVG的
2
CSS100Day(2)-菜单按钮动画
设计灵感 菜单按钮都见过,但是三根条动画实现,关键利用no-animation初始化时候关闭回复动画
3
CSS100Day(21)-利用svg线段实现吃小球动画
设计灵感 利用svg线段实现吃小球动画
4
CSS100Day(16)-利用before、after伪元素完成长方形散花动画
设计灵感 伪元素实现长方形散花动画
5
CSS100Day(3)-clip-path和动画实现金字塔日出日落
设计灵感 一个训练clip-path和关键帧贝塞尔曲线的练习
随机文章
随机推荐