灯笼效果(html+css)

<template>
  <div>
    <div class="lantern-box left">
      <div class="lantern-line"></div>
      <div class="lantern-body">
        <!-- 灯笼中间的线条 -->
        <div class="lantern-circle">
          <div class="lantern-rect">
            <!-- 灯笼中间的文字内容 -->
            <div class="lantern-text">福</div>
          </div>
        </div>
        <!-- 灯笼穗 -->
        <div class="lantern-tassel"></div>
      </div>
    </div>
    <div class="lantern-box right">
      <div class="lantern-line"></div>
      <div class="lantern-body">
        <!-- 灯笼中间的线条 -->
        <div class="lantern-circle">
          <div class="lantern-rect">
            <!-- 灯笼中间的文字内容 -->
            <div class="lantern-text">福</div>
          </div>
        </div>
        <!-- 灯笼穗 -->
        <div class="lantern-tassel"></div>
      </div>
    </div>
  </div>
</template>
<style lang="less" scoped>
.lantern-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  /* 设置旋转点 */
  transform-origin: top center;
  animation: swing 3s infinite ease-in-out;
  position: relative;
  z-index: 999;
}

.left {
  position: fixed;
  left: 20px;
  top: 0;
}

.right {
  position: fixed;
  right: 20px;
  top: 0;
}

.lantern-line {
  width: 5px;
  height: 80px;
  background-color: #dc8f03;
}

.lantern-body {
  position: relative;
  width: 250px;
  height: 170px;
  background-color: #f00;
  border-radius: 120px;
  //   水平,垂直,模糊半径,阴影大小,颜色,内阴影
  // 可用逗号分隔多个阴影,制作复杂重叠阴影效果
  box-shadow: 0 30px 115px -10px #f00 inset, 0 0 10px #f00;
  box-shadow: 0 30px 115px -10px #f00;
  /* 设置旋转点 */
  transform-origin: top center;
  animation: swing 3s infinite ease-in-out;
}

.lantern-body::before {
  content: "";
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translate(-50%, 0);
  width: 100px;
  height: 20px;
  background-color: #dc8f03;
  border-radius: 5px 5px 0 0;
}

.lantern-body::after {
  content: "";
  position: absolute;
  bottom: -20px;
  left: 50%;
  transform: translate(-50%, 0);
  width: 100px;
  height: 20px;
  background-color: #dc8f03;
  border-radius: 0 0 5px 5px;
}

/* 灯笼的动画效果 */
@keyframes swing {
  0% {
    transform: rotate(-6deg);
  }

  50% {
    transform: rotate(6deg);
  }

  100% {
    transform: rotate(-6deg);
  }
}

.lantern-circle {
  position: absolute;
  top: -5px;
  left: 50%;
  transform: translate(-50%, 0);
  width: 200px;
  height: 190px;
  border: 2px solid #dc8f03;
  border-radius: 50%;
}

.lantern-rect {
  display: flex;
  flex-direction: column;
  position: absolute;
  top: -5px;
  left: 50%;
  transform: translate(-50%, 0);
  width: 90px;
  height: 240px;
  border: 2px solid #dc8f03;
  border-radius: 50%;
}

.lantern-text {
  position: absolute;
  top: 42%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 20px;
  font-family: "楷体";
  /*设置字体*/
  font-size: 64px;
  /*设置字体大小*/
  font-weight: bold;
  /*设置字体粗细*/
  -webkit-text-stroke: 1px rgb(255, 183, 0);
  /*文字描边*/
  -webkit-text-fill-color: transparent;
  /*设置文字的填充颜色*/
  -webkit-animation: shine 3s infinite;
  /*设置动画 字体阴影闪烁*/
}

@-webkit-keyframes shine {
  0% {
    text-shadow: 0 0 5px rgb(255, 183, 0), 0 0 5px rgb(255, 183, 0);
  }

  100% {
    text-shadow: 0 0 50px rgb(255, 183, 0), 0 0 50px rgb(255, 183, 0);
  }
}

.lantern-tassel {
  position: absolute;
  bottom: -45%;
  left: 50%;
  transform: translate(-50%, 0);
  width: 5px;
  height: 75px;
  background-color: #dc8f03;
  /* 设置旋转点 */
  animation: swing 3s infinite ease-in-out;
}

.lantern-tassel::before {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translate(-50%, 0);
  width: 30px;
  height: 30px;
  background-color: #dc8f03;
  border-radius: 50%;
}

.lantern-tassel::after {
  content: "";
  position: absolute;
  bottom: -100%;
  left: 50%;
  transform: translate(-50%, 20%);
  width: 20px;
  height: 100px;
  background-color: #ffa500;
  border-radius: 0 0 5px 10px;
}

@media screen and (max-width: 1500px) {
  .lantern-box {
    // display: none;
  }
}
</style>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

猛男敲代码

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值