CSS3鼠标hover图片光芒四射动画特效代码

CSS3鼠标hover图片光芒四射动画特效代码

这是一款CSS3鼠标hover图片光芒四射动画特效。该特效中,当鼠标Hover图片的时候,通过对伪元素添加渐变和clip-path,来制作光芒四射的效果,非常炫酷。

HTML结构
该特效中图片和它的容器的基本HTML结构如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
<div class="box">
    <img src="images/img-1.jpg">
    <div class="box-content">
        <div class="inner-content">
            <h3 class="title">孙悟空</h3>
            <span class="post">七龙珠</span>
        </div>
        <ul class="icon">
            <li><a href="#"><i class="fa fa-search"></i></a></li>
            <li><a href="#"><i class="fa fa-link"></i></a></li>
        </ul>
    </div>
</div>

CSS样式
然后为该CSS3鼠标hover图片光芒四射动画特效添加下面的CSS代码:

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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
.box{
    border-radius: 10px;
    overflow: hidden;
    perspective: 800px;
    position: relative;
}
   
.box:before{
    content: "";
    width: 100%;
    height: 100%;
    background: linear-gradient(36deg, #272b66 42.34%, transparent 42.34%) 0 0,
   linear-gradient(72deg, #2d559f 75.48%, transparent 75.48%) 0 0,
   linear-gradient(-36deg, #9ac147 42.34%, transparent 42.34%) 100% 0,
   linear-gradient(-72deg, #639b47 75.48%, transparent 75.48%) 100% 0,
   linear-gradient(36deg, transparent 57.66%, #e1e23b 57.66%) 100% 100%,
   linear-gradient(72deg, transparent 24.52%, #f7941e 24.52%) 100% 100%,
   linear-gradient(-36deg, transparent 57.66%, #662a6c 57.66%) 0 100%,
   linear-gradient(-72deg, transparent 24.52%, #9a1d34 24.52%) 0 100%,
   #43a1cd linear-gradient(#ba3e2e, #ba3e2e) 50% 100%;
   background-repeat: no-repeat;
    background-size: 50% 50%;
    opacity: 0;
    position: absolute;
    top: 50%;
    left: 50%;
    -webkit-clip-path: polygon(50% 0%, 90% 20%, 100% 60%, 75% 100%, 25% 100%, 0% 60%, 10% 20%);
    clip-path: polygon(50% 0%, 90% 20%, 100% 60%, 75% 100%, 25% 100%, 0% 60%, 10% 20%);
    transform: translateX(-50%) translateY(-50%) scale(0) rotate(360deg);
    transition: all 0.3s ease 0s;
}
   
.box:hover:before{
    opacity: 0.5;
    transform: translateX(-50%) translateY(-50%) scale(1.5) rotate(0);
}
   
.box:after{
    content: "";
    width: 100%;
    height: 100%;
    background: radial-gradient(rgba(255,255,255,0.9),transparent,transparent);
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
}
   
.box:hover:after{ opacity: 1; }
   
.box img{
    width: 100%;
    height: auto;
}
   
.box .box-content{
    width: 100%;
    height: 100%;
    text-align: center;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}
   
.box .inner-content{
    width: 100%;
    color: #fff;
   position: absolute;
    top: 50%;
    left: 50%;
    opacity: 0;
    z-index: 2;
    transform: translate(-50%, -50%) scale(2);
    transition: all 0.3s ease 0.2s;
}
   
.box:hover .inner-content{
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}
   
.box .title{
    font-size: 25px;
    font-weight: 600;
    color: #3e0e0c;
   text-transform: uppercase;
    margin: 0 0 5px 0;
    position: relative;
    transition: all 0.3s ease 0.2s;
}
   
.box .post{
    display: inline-block;
    font-size: 13px;
    font-weight: 600;
    color: #3e0e0c;
   text-transform: capitalize;
    letter-spacing: 2px;
}
   
.box .icon{
    width: 100%;
    padding: 0;
    margin: 0;
    list-style: none;
    position: absolute;
    bottom: -100%;
    left: 50%;
    transform: translateX(-50%);
    transition: all 0.3s ease 0.2s;
}
   
.box:hover .icon{ bottom: 15px; }
   
.box .icon li{
    display: inline-block;
    margin: 0 2px;
}
   
.box .icon li a{
    display: block;
    width: 40px;
    height: 40px;
    line-height: 40px;
    border-radius: 30%;
    background: #fff;
   font-size: 20px;
    color: #3e0e0c;
   transition: all 0.3s ease 0s;
}
   
.box .icon li a:hover{
    background: #3e0e0c;
   color: #fff;
}
   
@media only screen and (max-width:990px){
    .box{ margin-bottom: 30px; }
}

文件信息:

    0

    发表评论