为元素添加背景模糊可以使其在视觉上更具吸引力,而且它也确实有用。那么,您不妨添加它,因为为什么不呢? ˙_(ツ)_/˙
您需要的代码行
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);
}
感谢您的阅读!祝你有美好的一天! ✨