You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何用CSS实现图像玻璃覆盖效果(含左侧白晕与嵌入感)

实现玻璃嵌入+左侧光晕的图像效果

以下是复现你所需效果的CSS方案,核心通过容器伪元素、模糊滤镜和渐变实现:

1. HTML结构

<div class="glass-image-container">
  <img src="你的图像URL" alt="展示图像" />
</div>

2. CSS实现代码

.glass-image-container {
  position: relative;
  width: 400px;
  height: 300px;
  border-radius: 8px;
  overflow: hidden;
  /* 玻璃质感核心:半透明背景+模糊滤镜 */
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(6px);
  /* 内阴影强化嵌入层次感 */
  box-shadow: inset 2px 2px 5px rgba(255, 255, 255, 0.1),
              inset -2px -2px 5px rgba(0, 0, 0, 0.2);
}

.glass-image-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.85; /* 降低透明度,模拟图像在玻璃后方的视觉 */
}

/* 左侧白色光晕效果 */
.glass-image-container::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 60px;
  background: linear-gradient(to right, rgba(255, 255, 255, 0.3), transparent);
  filter: blur(10px);
  pointer-events: none;
}

/* 右上角嵌入边框效果 */
.glass-image-container::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 60%;
  height: 60%;
  border-top: 2px solid rgba(0, 0, 0, 0.15);
  border-right: 2px solid rgba(0, 0, 0, 0.15);
  border-radius: 0 8px 0 0;
  pointer-events: none;
}

效果说明

  • 玻璃质感:通过backdrop-filter: blur()配合半透明背景实现,图像降低透明度后,呈现出“隔着玻璃”的朦胧感。
  • 左侧光晕:利用伪元素的线性渐变+模糊滤镜,模拟从左到右衰减的白色发光效果。
  • 嵌入边框:右上角的伪元素边框,搭配容器的内阴影,强化图像“嵌入”界面的视觉感受。

你可以根据实际需求调整尺寸、模糊程度、颜色透明度等参数,适配不同场景。

内容的提问来源于stack exchange,提问作者Digital

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.06 03:25:17