effect
FIG effect as
Realization of ideas
- div realization of a rectangular sun shadow
- before pseudo-rectangular light produced another, and conventional shift 90 °
- draw a circle after pseudo-elements to achieve style sun
dom structure
With two nested div container, the parent container control icon to appear, sub-containers used to write a pattern of light and shadow rectangle of sun.
<div class="container">
<div class="sunny"></div>
</div>
专门建立的学习Q-q-u-n ⑦⑧④-⑦⑧③-零①② 分享学习方法和需要注意的小细节,不停更新最新的教程和学习技巧(从零基础开始到前端项目实战教程,学习工具,全栈开发学习路线以及规划)
css styles
1, defines the parent container style, position control icon, the way to add the entire page background color, convenient preview
body{
background: rgba(73, 74, 95, 1);
}
.container{
width: 170px;
height: 170px;
position: relative;
margin: 250px auto;
}
2, a rectangular light pattern, there is a 360 ° rotation animation
.sunny{
width: 20px;
height: 140px;
position: absolute;
top: 20px;
left: 90px;
background: -webkit-linear-gradient(top, rgba(255,255,255,0) 0%, rgba(255,255,255,0.8) 50%, rgba(255,255,255,0) 100%);
animation: sunny 15s linear infinite;
}
@keyframes sunny {
0%{
transform: rotate(0deg);
}
100%{
transform: rotate(360deg);
}
}
3, a vertical writing another rectangular shadow
.sunny::before{
content: '';
width: 20px;
height: 140px;
position: absolute;
bottom: 0;
left: 0;
background: -webkit-linear-gradient(top, rgba(255,255,255,0) 0%, rgba(255,255,255,0.8) 50%, rgba(255,255,255,0) 100%);
transform: rotate(90deg)
}
4, the sun circle style
.sunny::after{
content: '';
width: 80px;
height: 80px;
position: absolute;
top: 30px;
left: -30px;
background: #ffee44;
border-radius: 50%;
box-shadow: rgba(255,255,0,0.2) 0 0 0 15px;
}