如何在html、css中创建玻璃效果?

问题描述 投票:0回答:1

我在 linktree 中看到了这个,我想知道如何在 html 和 css 中制作类似于这种玻璃渐变效果的东西。 Glassy gradient linktree effect (CLICK TO VIEW IMAGE)

html css gradient effects
1个回答
0
投票

您所指的玻璃效果称为glassmorphism。这是一种现代 UI 设计趋势,使用透明度、模糊和渐变来为元素创建类似玻璃的外观。使用 HTML 和 CSS 可以通过不同的方法来实现此效果,但最常见的方法是使用具有 blur 值和半透明背景色的 backdrop-filter 属性。

这是一个例子:

<div class="container">
  <div class="card">
    <h1>Glassmorphism</h1>
    <p>This is a glassy card with a gradient background.</p>
  </div>
</div>
.container {
  height: 100vh;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #ff00cc;
  background: -webkit-linear-gradient(to right, #333399, #ff00cc);
  background: linear-gradient(to right, #333399, #ff00cc);
}

.card {
  width: 400px;
  height: 300px;
  padding: 20px;
  border-radius: 20px;
  background-color: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
  color: white;
  font-family: Arial, sans-serif;
}

这将产生以下结果:

您还可以使用 glassmorphism CSS 生成器 通过不同的选项和设置创建您自己的玻璃效果。

© www.soinside.com 2019 - 2024. All rights reserved.