我正在尝试创建一个简单的小型前端项目,并且需要使一些文本可以从背景图像中辨别出来。
如何使文字背后的背景变得模糊?它只是模糊了容器,我只想模糊实际文本的后面。
我当前的文本代码:
.center h1 {
font-size: 100px;
font-style: italic;
font-family: 'Montserrat', sans-serif;
background: -webkit-linear-gradient(0deg,rgba(255, 255, 255, 0.75), rgba(255, 255, 255, 0.25));
background-clip: text;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
backdrop-filter: blur(10px);
}
/* added by editor for deomnstration purpose */
body {
background-image: url('https://upload.wikimedia.org/wikipedia/commons/5/5b/St_Mary%27s_Church%2C_Castle_Street_1.jpg');
background-size: cover;
}
.center {
position: fixed;
left: 50%;
top: 50%;
transform: translate(-50%, -100%);
text-align: center;
width: max-content;
}Run Code Online (Sandbox Code Playgroud)
<div class="center">
<h1>GLUSH</h1>
<!-- Added by original poster for better running -->
</div>Run Code Online (Sandbox Code Playgroud)
这只是这样结束:
有什么办法可以做到这一点吗?background-clip早些时候我正在与...
只需根据您的喜好使用backdrop-filter和使用blur和过滤器即可。明显模糊了背景,同时赋予它更多的“颜色深度”saturateblursaturate
h1 {
backdrop-filter: blur(10px) saturate(70%);
}
/* to make the header only as wide as the content and centering it */
h1 {
width: min-content;
padding: 20px;
margin: 0 auto;
}
/* added by editor for deomnstration purpose */
body {
background-image: url('https://upload.wikimedia.org/wikipedia/commons/5/5b/St_Mary%27s_Church%2C_Castle_Street_1.jpg');
background-size: cover;
}
h1 {
font-size: 5em;
}Run Code Online (Sandbox Code Playgroud)
<h1>GLUSH</h1>Run Code Online (Sandbox Code Playgroud)