纯css代码画灯笼,废话不多说,大家直接复制代码就可以用,代码有详细注释。
<!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>元宵快乐</title>
<style>
:root {
--lineColor: #ecaa2f;
--bg: #f00;
background: url(./veg.jpg) no-repeat;
background-size: cover;
}
.container {
position: relative;
width: 200px;
height: 150px;
animation: rotate 3s infinite ease-in;
}
.center {
position: relative;
width: 100%;
height: 100%;
background-color: var(--bg);
border-radius: 80px;
box-shadow: 0 0 80px var(--bg);
animation: rotate 3s infinite ease-in-out;
transform-origin: top center;
}
.center::before {
position: absolute;
content: "";
display: block;
width: 80px;
height: 10px;
top: -8px;
left: 50%;
transform: translateX(-50%);
background: var(--lineColor);
border-radius: 5px 5px 0 0;
}
.center::after {
position: absolute;
content: "";
display: block;
width: 80px;
height: 10px;
bottom: -8px;
left: calc(50% - 40px);
background: var(--lineColor);
border-radius: 0 0 5px 5px;
}
.center-line {
position: relative;
width: 100%;
height: 100%;
}
.center-line span {
position: absolute;
top: calc(50%);
left: calc(50%);
transform: translate(-50%, -50%);
width: 18px;
font-size: 18px;
color: var(--lineColor);
font-weight: 700;
}
.center-line::before {
position: absolute;
content: "";
top: 0;
left: calc(50% - 75px);
width: 150px;
height: 150px;
border: 2px solid var(--lineColor);
border-radius: 50%;
}
.center-line::after {
position: absolute;
content: "";
display: block;
top: 0;
left: calc(50% - 35px);
width: 70px;
height: 150px;
border: 2px solid var(--lineColor);
border-radius: 50%;
}
.head-line {
position: absolute;
left: calc(50% - 2px);
top: -60px;
width: 4px;
height: 60px;
background-color: var(--lineColor);
}
.footer-line {
position: absolute;
left: calc(50% - 2px);
bottom: -50px;
width: 4px;
height: 50px;
background-color: var(--lineColor);
animation: rotate 3s infinite ease-in-out;
}
.footer-line::after {
position: absolute;
content: "";
bottom: -75px;
left: calc(50% - 8px);
width: 16px;
height: 80px;
background: -webkit-linear-gradient(#f00,
#e36d00 3px,
#fbd342 5px,
#e36d00 8px,
#e36d00 12px,
#f00 16px,
rgba(255, 0, 0, 0.8) 26px,
rgba(255, 0, 0, 0.6));
border-radius: 5px 5px 0 0;
}
@keyframes rotate {
0%,
100% {
transform: rotate(-10deg);
}
50% {
transform: rotate(10deg);
}
}
.left {
float: left;
}
.right {
float: right;
}
.duilian.left {
position: absolute;
top: 130px;
left: 394px;
background-color: #f00;
height: 300px;
width: 45px;
}
.duilian.right {
position: absolute;
top: 130px;
right: 394px;
background-color: #f00;
height: 300px;
width: 45px;
}
.duilian.top {
position: absolute;
top: 30px;
right: calc(50% - 100px);
background-color: #f00;
height: 45px;
width: 200px;
font-size: 32px;
text-align: center;
line-height: 45px;
}
.duilian span {
display: block;
font-size: 32px;
text-align: center;
width: 45px;
}
</style>
</head>
<body>
<div class="app">
<div class="container left">
<span class="head-line"></span>
<div class="center">
<div class="center-line">
<span>元旦快乐</span>
</div>
<span class="footer-line"></span>
</div>
</div>
<div class="container right">
<span class="head-line"></span>
<div class="center">
<div class="center-line">
<span>元旦快乐</span>
</div>
<span class="footer-line"></span>
</div>
</div>
<div class="duilian left">
<span>
满帘花影月三五
</span>
</div>
<div class="duilian right">
<span>
一碗汤圆情万千
</span>
</div>
<div class="duilian top">元宵纳福</div>
</div>
</body>
</html>