前几天看到了旧日足迹挂上了灯笼特效,看起来挺好看的,于是就添加到了我的博客中。
可是这几天年也过完了,再挂着灯笼有点不舒服,于是我就想要不就把灯笼换成其他样式吧,于是这个油灯一样的灯就出现了。
我把春节灯笼和现在这个灯的代码都会放在下面。
油灯效果
旧日足迹 博客灯笼效果
只在首页显示找到index.php在合适位置添加以下代码,如果整站都显示可加在footer或header文件内
在公共css里面添加如下代码例如style.css文件,也可以在页面样式里面()直接添加
灯笼效果代码
HTML
<div class="deng-box">
<div class="deng">
<div class="xian"></div>
<div class="deng-a">
<div class="deng-b"><div class="deng-t">欢</div></div>
</div>
<div class="shui shui-a"><div class="shui-c"></div><div class="shui-b"></div></div>
</div>
</div>
<div class="deng-box1">
<div class="deng">
<div class="xian"></div>
<div class="deng-a">
<div class="deng-b"><div class="deng-t">迎</div></div>
</div>
<div class="shui shui-a"><div class="shui-c"></div><div class="shui-b"></div></div>
</div>
</div>
css
.deng-box {
position: fixed;
top: -30px;
left: -10px;
z-index: 9999;
pointer-events: none;
}
.deng-box1 {
position: fixed;
top: -30px;
right: 5px;
z-index: 9999;
pointer-events: none;
}
.deng-box1 .deng {
position: relative;
width: 120px;
height: 90px;
margin: 50px;
background: #d8000f;
background: rgba(216, 0, 15, 0.8);
border-radius: 50% 50%;
-webkit-transform-origin: 50% -100px;
-webkit-animation: swing 5s infinite ease-in-out;
box-shadow: -5px 5px 30px 4px rgba(252, 144, 61, 1);
}
.deng {
position: relative;
width: 120px;
height: 90px;
margin: 50px;
background: #d8000f;
background: rgba(216, 0, 15, 0.8);
border-radius: 50% 50%;
-webkit-transform-origin: 50% -100px;
-webkit-animation: swing 3s infinite ease-in-out;
box-shadow: -5px 5px 50px 4px rgba(250, 108, 0, 1);
}
.deng-a {
width: 100px;
height: 90px;
background: #d8000f;
background: rgba(216, 0, 15, 0.1);
margin: 12px 8px 8px 10px;
border-radius: 50% 50%;
border: 2px solid #dc8f03;
}
.deng-b {
width: 45px;
height: 90px;
background: #d8000f;
background: rgba(216, 0, 15, 0.1);
margin: -2px 8px 8px 26px;
border-radius: 50% 50%;
border: 2px solid #dc8f03;
}
.xian {
position: absolute;
top: -20px;
left: 60px;
width: 2px;
height: 20px;
background: #dc8f03;
}
.shui-a {
position: relative;
width: 5px;
height: 20px;
margin: -5px 0 0 59px;
-webkit-animation: swing 4s infinite ease-in-out;
-webkit-transform-origin: 50% -45px;
background: #ffa500;
border-radius: 0 0 5px 5px;
}
.shui-b {
position: absolute;
top: 14px;
left: -2px;
width: 10px;
height: 10px;
background: #dc8f03;
border-radius: 50%;
}
.shui-c {
position: absolute;
top: 18px;
left: -2px;
width: 10px;
height: 35px;
background: #ffa500;
border-radius: 0 0 0 5px;
}
.deng:before {
position: absolute;
top: -7px;
left: 29px;
height: 12px;
width: 60px;
content: " ";
display: block;
z-index: 999;
border-radius: 5px 5px 0 0;
border: solid 1px #dc8f03;
background: #ffa500;
background: linear-gradient(to right, #dc8f03, #ffa500, #dc8f03, #ffa500, #dc8f03);
}
.deng:after {
position: absolute;
bottom: -7px;
left: 10px;
height: 12px;
width: 60px;
content: " ";
display: block;
margin-left: 20px;
border-radius: 0 0 5px 5px;
border: solid 1px #dc8f03;
background: #ffa500;
background: linear-gradient(to right, #dc8f03, #ffa500, #dc8f03, #ffa500, #dc8f03);
}
.deng-t {
font-family: 华文行楷,Arial,Lucida Grande,Tahoma,sans-serif;
font-size: 3.2rem;
color: #dc8f03;
font-weight: bold;
line-height: 85px;
text-align: center;
}
.night .deng-t,
.night .deng-box,
.night .deng-box1 {
background: transparent !important;
}
@-moz-keyframes swing {
0% {
-moz-transform: rotate(-10deg)
}
50% {
-moz-transform: rotate(10deg)
}
100% {
-moz-transform: rotate(-10deg)
}
}
@-webkit-keyframes swing {
0% {
-webkit-transform: rotate(-10deg)
}
50% {
-webkit-transform: rotate(10deg)
}
100% {
-webkit-transform: rotate(-10deg)
}
}
油灯效果代码
HTML
<div class="scene">
<div class="lantern">
<div class="lantern-inner">
<div class="lantern-chain"></div>
<div class="lantern-head"></div>
<div class="lantern-body">
<div class="lantern-spark"></div>
<div class="lantern-spark"></div>
<div class="lantern-spark"></div>
<div class="lantern-flame"></div>
</div>
<div class="lantern-base"></div>
</div>
</div>
<div class="planets">
<div class="planet"></div>
<div class="planet"></div>
<div class="planet"></div>
<div class="planet"></div>
<div class="planet"></div>
<div class="planet"></div>
</div>
</div>
css
/*小油灯效果*/
.scene {
position: fixed;
height: 500px;
right: 100px;
z-index: 9999;
pointer-events: none;
}
.scene::before {
--c-bg: hsl(262,39%,22%);
--c-glow: hsl(262,39%,20%);
--size: 600px;
animation: scene-anim .6s infinite steps(6);
background: var(--c-bg);
border-radius: var(--size);
box-shadow: inset 0 0 0 3px var(--c-glow);
content: '';
height: var(--size);
left: calc(50% - (var(--size) /2));
position: absolute;
top: -50px;
}
@keyframes scene-anim {
0% {
box-shadow: inset 0 0 0 3px var(--c-glow);
}
20% {
box-shadow: inset 0 0 0 8px var(--c-glow);
}
40% {
box-shadow: inset 0 0 0 2px var(--c-glow);
}
60% {
box-shadow: inset 0 0 0 6px var(--c-glow);
}
80% {
box-shadow: inset 0 0 0 3px var(--c-glow);
}
100% {
box-shadow: inset 0 0 0 5px var(--c-glow);
}
}
.lantern {
--c-lantern-body: hsl(262,38%,20%);
--c-lantern-light: hsl(23,98%,75%);
--c-lantern-glow: hsl(343,83%,63%);
display: flex;
flex-direction: column;
left: calc(50%);
position: absolute;
transform: translateX(-50%);
z-index: 1;
}
.lantern-inner {
animation: lantern-anim 1.2s ease-in-out alternate infinite;
margin-top: -5px;
transform-origin: top center;
}
.lantern-chain {
height: 60px;
}
.lantern-chain::before {
--c: hsl(260,38%,34%);
background-color: var(--c);
box-shadow:
0 0 0 5px var(--c),
0 20px 0 var(--c),
0 35px 0 var(--c),
0 50px 0 var(--c);
border-radius: 50%;
content: '';
display: block;
height: 10px;
margin: 0 auto;
width: 10px;
}
.lantern-head::before,
.lantern-head::after {
background: var(--c-lantern-body);
border-radius: 5px;
content: '';
display: block;
height: 15px;
}
.lantern-head::before {
margin: 0 auto;
width: 100px;
}
.lantern-head::after {
border-radius: 3px;
height: 30px;
margin: 3px auto;
width: 60px;
}
.lantern-body {
perspective: 350px;
position: relative;
}
.lantern-body::before {
border: 8px solid var(--c-lantern-body);
border-radius: 50px;
box-shadow:
inset 0 0 0 5px var(--c-lantern-light),
inset 0 0 0 20px var(--c-lantern-glow);
content: '';
display: block;
height: 195px;
margin: 0 auto;
perspective: 100px;
transform: rotateX(20deg) translateY(-20px);
transform-origin: center center;
width: 120px;
}
.lantern-body::after {
--c: hsl(321,41%,42%);
background-color: var(--c);
border-radius: 4px;
box-shadow: -5px 161px 0 1px var(--c), 5px 161px 0 1px var(--c);
content: '';
display: block;
height: 7px;
margin: -7px auto 0;
transform: translateY(-195px);
width: 40px;
}
.lantern-spark {
animation: lantern-spark-anim linear 2s forwards infinite;
background:
radial-gradient(circle at center, var(--c-lantern-light) 60%, transparent 60%),
linear-gradient(to right, transparent 10%, #fff 50%, transparent 50%);
border-radius: 50%;
clip: rect(0px 30px 30px 0px);
height: 60px;
left: calc(50% - 30px);
position: absolute;
top: calc(45% - 30px);
transform-origin: center center;
width: 60px;
}
.lantern-spark:nth-child(2) {
animation-delay: calc(2s / 3);
}
.lantern-spark:nth-child(3) {
animation-delay: calc((2s / 3) * 2);
}
.lantern-flame {
background-color: #fff;
border-radius: 50%;
height: 30px;
left: calc(50% - 15px);
position: absolute;
top: calc(45% - 15px);
width: 30px;
}
.lantern-base {
background: var(--c-lantern-body);
border-radius: 5px;
display: block;
height: 15px;
margin: -15px auto 0;
width: 70px;
}
@keyframes lantern-anim {
0% {
transform: rotateZ(1deg);
}
100% {
transform: rotateZ(-1deg);
}
}
@keyframes lantern-spark-anim {
100% {
transform: rotateZ(360deg);
}
}
.planet {
--bg: hsl(257,39%,27%);
--light: hsl(348,88%,65%);
--orbit: 150px;
animation: planet-anim 5s forwards infinite;
background: var(--bg);
border: 2px solid var(--bg);
border-radius: 50%;
box-shadow: 0 0 5px rgba(0, 0, 0, .25);
height: 30px;
left: calc(50% - 15px);
overflow: hidden;
position: absolute;
top: 35%;
transform-origin: center center;
width: 30px;
}
.planet::before {
animation: planet-light-anim 2.5s forwards linear infinite;
background-color: var(--light);
border-radius: 50%;
content: '';
position: absolute;
top: -20px;
right: -20px;
bottom: -20px;
left: -20px;
}
.planet:nth-child(1) {
--orbit: 70px;
animation-delay: -.3s;
transform: scale(.9) translateY(-80px);
}
.planet:nth-child(2) {
--bg: hsl(344,83%,63%);
--light: hsl(19,98%,75%);
--orbit: 100px;
animation-delay: -2s;
animation-duration: 5.5s;
transform: scale(.8) translateY(-20px);
}
.planet:nth-child(3) {
--bg: hsl(344,83%,63%);
--light: hsl(19,98%,75%);
--orbit: 100px;
animation-delay: -4s;
animation-duration: 4.5s;
transform: scale(.4) translateY(100px);
}
.planet:nth-child(4) {
--bg: hsl(322,41%,43%);
--light: hsl(348,88%,65%);
--orbit: 120px;
animation-delay: -3.7s;
animation-duration: 4.2s;
transform: scale(.8) translateY(75px);
}
.planet:nth-child(5) {
--bg: hsl(322,41%,43%);
--light: hsl(348,88%,65%);
--orbit: 100px;
animation-delay: -1.3s;
animation-duration: 5.8s;
transform: scale(.4) translateY(40px);
}
.planet:nth-child(6) {
--orbit: 90px;
animation-delay: .5s;
animation-duration: 4.2s;
transform: scale(.9) translateY(150px);
}
@keyframes planet-anim {
0% {
margin-left: calc(var(--orbit) * -1);
z-index: 1;
}
50% {
margin-left: var(--orbit);
z-index: 1;
}
50.1% {
margin-left: var(--orbit);
z-index: 0;
}
100% {
margin-left: calc(var(--orbit) * -1);
z-index: 0;
}
}
@keyframes planet-light-anim {
0% {
transform: translateX(-100%);
}
50% {
transform: translateX(0);
}
100% {
transform: translateX(100%);
}
}
灯的样式很好看哦!博客主题很精简,字体也很文艺。感觉是个很棒的博客呢!
哈哈哈,谢谢 欢迎常来。
好大个油灯,嘿嘿。
哈哈哈,不碍事。