一条思路,一句代码,一种编程,一番人生,亲爱的观众朋友们大家好,欢迎来到——【基础编程】——杂谈之点击发送特效。让我们整理思路,重新出发。那么废话不多说,上代码。
//设置样式
* {
padding: 0;
margin: 0;
-webkit-font-smoothing: antialiased;//反锯齿
-moz-osx-font-smoothing: grayscale;//灰度级
box-sizing: inherit;
}
设置样式等。
*::after, *::before {
box-sizing: inherit;
}
body .send-button {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);//变圆
}
设置position: absolute;绝对定位
transform: translate(-50%, -50%);//变圆
变圆的弧度
@keyframes icon-animation {
0% {
transform: rotate(0deg) scale(1);
}
33% {
transform: rotate(-120deg) scale(4);
}
66% {
transform: rotate(-240deg) scale(4);
}
100% {
transform: rotate(-360deg) scale(1);
}
}
设置动画是这样变化的
//设置XYZ轴的动画
@keyframes input-shadow {
0% {
box-shadow: 0 3px 3px 0 rgba(0, 0, 0, 0.14),
0 1px 7px 0 rgba(0, 0, 0, 0.12), 0 3px 1px -1px rgba(0, 0, 0, 0.2);
}
40% {
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14),
0 1px 5px 0 rgba(0, 0, 0, 0.12), 0 3px 1px -2px rgba(0, 0, 0, 0.2);
}
50% {
box-shadow: none;
}
70% {
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14),
0 1px 5px 0 rgba(0, 0, 0, 0.12), 0 3px 1px -2px rgba(0, 0, 0, 0.2);
}
100% {
box-shadow: 0 3px 3px 0 rgba(0, 0, 0, 0.14),
0 1px 7px 0 rgba(0, 0, 0, 0.12), 0 3px 1px -1px rgba(0, 0, 0, 0.2);
}
}
设置动画是怎么样变化的
.icon-wrapper-animation {
animation: icon-animation 1.5s linear;
transition: color 0.6s ease;//颜色的变化
color: #66bb6a;
}
.clicked {
transform: translate(-50%, calc(-50% + 1px)) !important;
transition: transform 0.15s ease;
animation: input-shadow 0.15s ease;
box-shadow: 0 3px 3px 0 rgba(0, 0, 0, 0.14),
0 1px 7px 0 rgba(0, 0, 0, 0.12), 0 3px 1px -1px rgba(0, 0, 0, 0.2);
}
.clicked > .text {
transform: translateY(1px);
transition: transform 0.15s ease-out;
}
body .send-button {
background-color: #808080;
width: 95px;
height: 45px;
border-radius: 3px;
box-shadow: 0 4px 5px 0 rgba(0, 0, 0, 0.14),
0 1px 10px 0 rgba(0, 0, 0, 0.12), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
cursor: pointer;
user-select: none;
transition: transform 0.15s;
text-shadow: 1px 2px 1px rgba(77, 9, 36, 0.6);
}
body .send-button .text {
position: absolute;
left: 10px;
font-size: 22px;
font-size: 2.2rem;
letter-spacing: 1px;
line-height: 45px;
font-family: 'Microsoft YaHei','Lantinghei SC','Open Sans',
Arial,'Hiragino Sans GB','STHeiti','WenQuanYi Micro Hei','SimSun',sans-serif;
font-weight: 500;
color: #fff;
text-transform: uppercase;
}
body .send-button .icon-wrapper {
position: absolute;//绝对定位
right: -65px;
bottom: -10px;
width: 200px;
height: 200px;
border-radius: 50%;
line-height: 45px;
color: #fff;
}
body .send-button .icon-wrapper [class*="icon-"] {
position: absolute;
left: 100px;
bottom: 10px;
transition: color 0.6s ease;
}
body .send-button .icon-wrapper .icon-1 {
transform: rotate(15deg);
font-size: 23px;
font-size: 2.3rem;
opacity: 1;
}
body .send-button .icon-wrapper .icon-2 {
opacity: 0;//设置透明度 0~1
font-size: 25px;
font-size: 2.5rem;
}
<body>
<!-- 代码 开始 -->
<div class="send-button">
<span class="text">发送</span>
<span class="icon-wrapper">
<span class="icon-1 ion-paper-airplane"></span>
<span class="icon-2 ion-checkmark"></span>
</span>
</div>
<script src='js/jquery-2.2.4.min.js'></script>
<script type="text/javascript" src="js/index.js"></script>
<!-- 代码 结束 -->
</div>
</body>
留图