CSS特效——HOVER的相关应用(上)

CSS特效——HOVER的相关应用(上)

一、邮件发送

这是靠动画完成,当经过时触发动画,动画将左边的发送图标在一个流程中先向右移动到最右。再回到最初。
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" type="text/css" href="index.css">
</head>

<body>
    <button>
        <div class="after"></div>
        SEND
    </button>

</body>

</html>
*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
body{
    background-color: rgba(255, 255, 255, 0.733);
    position: relative;
}
button{
    position: absolute;
    padding-right: 10px;
    top: 100px;
    left: 40%;
    display: inline-block;
    width: 120px;
    height: 50px;
    border-radius: 10px;
    background-color: rgb(79, 122, 241);
    font-size: 20px;
    line-height: 50px;
    color: bisque;
    text-align: right;
}
button .after{
    position: absolute;
    background-image: url(a4c45f638275f9ef2baecdb3d26a75bd.jpg);
    height: 30px;
    width: 30px;
    background-repeat: no-repeat;
    background-position: center center;
    top: 10px;
    left: 10px;
}
button:hover .after{
    animation: fly 2s ease 1 ;
}
@keyframes fly {
    0%{
        transform:translateX(0%);
    }
    50%{
        transform:translateX(400%);
    }
    100%{
        transform:translateX(0%);
    }
}

二、霓虹灯效果

主要靠box-shadow 完成,
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" type="text/css" href="index.css">
</head>

<body>
    <div class="outer-box">
        <div class="one text-box">点击我</div>
        <div class="two text-box">点击我</div>
        <div class="three text-box">点击我</div>
    </div>

</body>

</html>
*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
body{
    position: relative;
    background-color: rgb(25, 30, 56);
}
.outer-box{
    position: absolute;
    top: 100px;
    left: 40%;
    display: inline-block;
    width: 360px;
    height: 60px;
    
}
.text-box{
    float: left;
    margin:0 10px;
    width: 100px;
    height: 60px;
    font-size: 25px;
    line-height: 60px;
    text-align: center;
    border-radius: 10px;
    
}
.one{
    border: 1px solid chartreuse;
    color: chartreuse;
}
.one:hover{
    color: cornsilk;
    background-color: chartreuse;
    -webkit-box-shadow:10px 10px 99px 6px chartreuse;
}
.two{
    border: 1px solid rgb(222, 224, 73);
    color: rgb(222, 224, 73);
}
.two:hover{
    color: cornsilk;
    background-color: rgb(222, 224, 73);
    -webkit-box-shadow:10px 10px 99px 6px rgb(222, 224, 73);
}
.three{
    border: 1px solid rgb(233, 69, 69);
    color: rgb(233, 69, 69);
}
.three:hover{
    color: cornsilk;
    background-color: rgb(233, 69, 69);
    -webkit-box-shadow:10px 10px 99px 6px rgb(233, 69, 69);
}

三、边框出现

主要靠动画效果完成,最开始是先设置伪元素边框透明。最后当经过时边框颜色设置成相应的颜色。
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" type="text/css" href="index.css">
</head>

<body>
    <div class="outer-box">
        HOVER ME
    </div>

</body>

</html>
*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
body{
    position: relative;
    background-color: rgb(206, 210, 228);
}
.outer-box{
    position: absolute;
    top: 100px;
    left: 40%;
    display: inline-block;
    width: 200px;
    height: 60px;
    font-size: 25px;
    line-height: 60px;
    text-align: center;
    color: rgb(79, 79, 238);
}
.outer-box::before, .outer-box::after {
    box-sizing: inherit;
    position: absolute ;
    content :'';
    border: 2px solid transparent ; 
    width: 0;
    height: 0;
    }
.outer-box::after{
    bottom:0;
    right: 0;
} 
.outer-box::before{
   left: 0;
   top: 0;
} 
.outer-box:hover::before, .outer-box:hover::after {
    width: 100% ;
    height: 100% ;
}
.outer-box:hover::before {
    border-top-color:#4361ee ;
    border-right-color: #4361ee ;
    transition: width 0.8s ease-out, height 0.8s ease-out 0.8s ;
}
.outer-box:hover::after {
    border-bottom-color: #4361ee;
    border-left-color:  #4361ee;
    transition: width 0.8s ease-out 1.6s, height 0.8s ease-out 2.4s ;
}
@keyframes width {
    0%{
        transform:translateX(-100%);
    }
    
    100%{
        transform:translateX(100%);
    }
}
@keyframes height {
    0%{
        transform:translateY(-100%);
    }
    
    100%{
        transform:translateY(100%);
    }
}
未完待续……
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

痞子三分冷ゾジ

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值