使用 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;

参考链接

相关推荐
岱宗夫up1 小时前
FastAPI入门(上篇):快速构建高性能Python Web API
开发语言·前端·python·fastapi
紫陌涵光2 小时前
112. 路径总和
java·前端·算法
漠月瑾-西安2 小时前
CVE-2025-55182漏洞解析:你的React项目安全吗?
前端·安全·react.js
No丶slovenly2 小时前
flutter笔记-输入框
前端·笔记·flutter
国产化创客3 小时前
ESP32+Web实现智能气象站
前端·物联网·智能家居·智能硬件
coderYYY3 小时前
VSCode终端启动报错
前端·ide·vscode·npm·编辑器
tod1134 小时前
Redis 数据类型与 C++ 客户端实践指南(redis-plus-plus)
前端·c++·redis·bootstrap·html
Sylvia33.4 小时前
火星数据:棒球数据API
java·前端·人工智能
weixin199701080164 小时前
1688商品详情页前端性能优化实战
前端·性能优化
DEMO派5 小时前
前端常用XSS攻击演示与防御方案解析
前端·xss