使用 CSS 实现 Logo 阴影特效

实现效果

在线演示

实现

HTML 元素:

html 复制代码
<figure>
  <section class="img-bg"></section>
  <img height="320" width="320" src="https://vitejs.dev/logo-with-shadow.png" alt="Vite Logo" />
</figure>

CSS 样式代码:

css 复制代码
.img-bg {
  position: absolute;
  background-image: linear-gradient(-45deg, #bd34fe 50%, #47caff 50%);
  border-radius: 50%;
  filter: blur(72px);
  z-index: -1;
  animation: pulse 4s cubic-bezier(0, 0, 0, 0.5) infinite;
}

@keyframes pulse {
  50% {
    transform: scale(1.5);
  }
}

实现 Logo 阴影特效的核心样式就在这几行 CSS 中。以下分部解释每行样式的作用:

1. 增加背景

css 复制代码
  background-image: linear-gradient(-45deg, #bd34fe 50%, #47caff 50%);

2. 将背景设置为圆形

css 复制代码
  border-radius: 50%;

3. 加入关键的 filter 属性 将模糊的图形效果应用于元素

css 复制代码
  filter: blur(72px);

4. 将背景至于图形底部

css 复制代码
  z-index: -1;

5. 加入动画效果

css 复制代码
  animation: pulse 4s cubic-bezier(0, 0, 0, 0.5) infinite;

参考链接

相关推荐
陆枫Larry35 分钟前
小程序包体积优化:用 SVG 图片替换 iconfont,并保留 CSS 控色能力
前端
环境栈笔记2 小时前
多账号浏览器选型检查清单:Profile、权限、Session 和任务日志怎么评估
前端·人工智能·后端·自动化
前端炒粉2 小时前
手写promise
java·前端·javascript
LaughingZhu2 小时前
智能体经典范式构建:ReAct、Plan-and-Solve 与 Reflection
前端·react.js·前端框架
jsonbro2 小时前
手把手带你实现发布订阅模式
前端·vue.js·设计模式
一只猫的梦2 小时前
自动化模块 (Automation Module)
前端·chrome
熊猫钓鱼>_>3 小时前
Electron:当 Web 技术统治桌面
大数据·前端·javascript·人工智能·架构·electron·agent
德福危险3 小时前
从盲打xss到到模板注入:unix靶机渗透之Tempus_fugit4
前端·unix·xss
JavaGuide3 小时前
又一个画图 Skill 开源,再见手动画 draw.io!
前端·后端·github
一只猫的梦3 小时前
AI 适配器架构
前端·chrome