卓越飞翔博客卓越飞翔博客

卓越飞翔 - 您值得收藏的技术分享站
技术文章68847本站已运行4219

用一行 CSS 添加背景模糊

为元素添加背景模糊可以使其在视觉上更具吸引力,而且它也确实有用。那么,您不妨添加它,因为为什么不呢? ˙_(ツ)_/˙

您需要的代码行

backdrop-filter: blur(5px);

除此之外,请确保背景模糊的元素不是纯色而是有点透明。并且,确保该元素的背景也不是纯色。

完整代码/示例

html

<h1>subscribe to axorax!</h1>

css

body {
  background: url("./nature.jpg") no-repeat center center / cover;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100dvh;
  font-family: "arial", sans-serif;
}

h1 {
  padding: 1.5rem;
  border-radius: 10px;
  color: #ffffff;
  /* ↓ Important ↓ */
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(5px);
}

用一行 CSS 添加背景模糊

感谢您的阅读!祝你有美好的一天! ✨

卓越飞翔博客
上一篇: 网格布局:创建复杂的布局
下一篇: 返回列表
留言与评论(共有 0 条评论)
   
验证码:
隐藏边栏