CSS之霓虹灯发光环

17 篇文章 0 订阅

效果演示

实现了一个旋转的加载器,其中包含四个小圆圈,每个小圆圈的背景颜色是渐变色,并且有不同的模糊程度。整个加载器的背景颜色是深蓝色。加载器旋转的动画效果是由CSS的animation属性实现的。加载器旋转完成后,会显示一个深蓝色的圆圈,作为加载完成的提示。

Code

<div class="loader">
    <span></span>
    <span></span>
    <span></span>
    <span></span>
</div>
body {
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: #240229;
}

.loader {
    position: relative;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(#14ffe9, #ffeb3b, #ff00e0);
    animation: animate 0.8s linear infinite;
}

@keyframes animate {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.loader span {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: linear-gradient(#14ffe9, #ffeb3b, #ff00e0);
    animation: animate 0.8s linear infinite;
}

.loader span:nth-child(1) {
    filter: blur(5px);
}

.loader span:nth-child(2) {
    filter: blur(10px);
}

.loader span:nth-child(3) {
    filter: blur(25px);
}

.loader span:nth-child(4) {
    filter: blur(50px);
}

.loader:after {
    content: '';
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    bottom: 10px;
    background: #240229;
    border-radius: 50%;
}

实现思路拆分

body {
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background: #240229; /* 设置页面的背景颜色为深蓝色 */
}

这段代码设置了页面的基本样式,包括边距、内边距、居中显示、高度和背景颜色等。

.loader {
  position: relative;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: linear-gradient(#14ffe9, #ffeb3b, #ff00e0); /* 设置加载器的背景颜色为渐变色 */
  animation: animate 0.8s linear infinite; /* 设置加载器旋转的动画效果 */
}

这段代码设置了加载器的基本样式,包括定位、宽度、高度、圆角半径、背景颜色和动画效果等。

@keyframes animate {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

这段代码定义了一个动画效果,包括从0度到360度旋转的动画。

.loader span {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: linear-gradient(#14ffe9, #ffeb3b, #ff00e0); /* 设置小圆圈的背景颜色为渐变色 */
  animation: animate 0.8s linear infinite; /* 设置小圆圈旋转的动画效果 */
}

这段代码设置了小圆圈的基本样式,包括定位、宽度、高度、圆角半径、背景颜色和动画效果等。

.loader span:nth-child(1) {
  filter: blur(5px); /* 设置第一个小圆圈的模糊程度为5px */
}

.loader span:nth-child(2) {
  filter: blur(10px); /* 设置第二个小圆圈的模糊程度为10px */
}

.loader span:nth-child(3) {
  filter: blur(25px); /* 设置第三个小圆圈的模糊程度为25px */
}

.loader span:nth-child(4) {
  filter: blur(50px); /* 设置第四个小圆圈的模糊程度为50px */
}

这段代码设置了每个小圆圈的模糊程度,使得它们看起来像是被模糊了。

.loader:after {
  content: '';
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  bottom: 10px;
  background: #240229; /* 设置加载器完成后的提示圆圈的背景颜色为深蓝色 */
  border-radius: 50%; /* 设置提示圆圈的圆角半径为50% */
}

这段代码设置了加载器完成后的提示圆圈的样式,包括定位、背景颜色和圆角半径等。

  • 4
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值