# 纯CSS3实现悬停时出现对角线耀光效果的按钮

# 快速导航

# 示例效果



# 示例代码

示例代码
<template>
   <div class="example-xuantingduijiao">
        <div class="btn-wrapper"><a class="btn">悬停对角线耀光</a></div>
   </div>

</template>
<style>
.example-xuantingduijiao {
    background: #BFFFBC;
}
.btn-wrapper {
    display: block;
    position: absolute;
    top: 50%;
    left: 50%;
    margin: -28px 0 0 -74.5px;
    box-shadow: 0 0 10px -10px black;
}
.btn {
    display: block;
    background: #A09EBB;
    padding: 20px 40px;
    position: relative;
    z-index: 0;
    overflow: hidden;
    cursor: pointer;
    border-radius: 2px;
    color: #FFF;
    border-bottom: 3px solid #6c3b96;
    font-weight: bold;
    font-family: sans-serif;
    letter-spacing: 1px;
}
.btn:after {
    content: "";
    display: block;
    position: absolute;
    z-index: 1;
    background: white;
    width: 150%;
    height: 100%;
    bottom: -80px;
    right: 40px;
    transform: rotate(30deg);
}
.btn-wrapper:hover {
    box-shadow: 0 10px 20px -10px black;
}
.btn-wrapper:hover a {
    animation: grow 600ms ease-in-out forwards;
}
.btn-wrapper:hover a:after {
    animation: shine 2s ease-in-out forwards;
    animation-iteration-count: infinite;
}
@keyframes shine {
    from {
        transform: translateX(0px) translateY(0px) rotate(30deg);
        opacity: 0.1;
    }
    to {
        transform: translateX(200px) translateY(-300px) rotate(30deg);
        opacity: 1;
    }
}
@keyframes grow {
    from {
        transform: scale(1);
    }
    to {
        transform: scale(1.1);
    }
}
</style>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74

实现这个效果,主要是结合css3中的transform,以及动画关键帧@keyframes实现

白色

关注公众号

一个走心,有温度的号,同千万同行一起交流学习

加作者微信

扫二维码 备注 【加群】

扫码易购

福利推荐