This是我能找到的最接近的。但不是文字是黑色的。我希望它有無限的背景剪裁。如何模糊背景並仍然能夠將未模糊背景剪輯到文本中?
嘗試1:
*{
padding:0;
margin:0;
}
/*Centering*/
html,body{
height:100%;
overflow:hidden;
}
.box{
height:100%;
display:flex;
justify-content:center;
align-items:center;
}
/*Clip text*/
.item{
font-size:250px;
z-index:1;
}
.box{
background:url('https://media.timeout.com/images/103444978/image.jpg');
background-size:cover;
}
/*Blurring*/
.box::before{
content:'';
background:inherit;
filter:blur(10px);
position:absolute;
top:0;right:0;bottom:0;left:0;
margin:-20px;
}
<div class='box'>
<div class='item'>NYC</div>
</div>
這個問題似乎是Z-指數之間的衝突:-webkit-背景夾1套在.item類和:文本;屬性。您不能將2合在一起,否則,屏幕將變爲空白。 z-index:1用於將文本放在模糊的背景之前。
This是我試圖將模糊和裁剪效果放在一起的地方。我在.item類中註釋了z-index:1,所以頁面不會變爲空白。
學嘗試2:
*{
padding:0;
margin:0;
}
/*Centering*/
html,body{
height:100%;
overflow:hidden;
}
.box{
height:100%;
display:flex;
justify-content:center;
align-items:center;
}
/*Clip text*/
.item{
font-size:250px;
/*z-index:1;*/
}
.box{
background:url('https://media.timeout.com/images/103444978/image.jpg');color:#21537a;/*text color for nonwebkit*/
-webkit-text-fill-color: transparent;
background-size:cover;
-webkit-background-clip:text;
}
/*Blurring*/
.box::before{
content:'';
background:inherit;
filter:blur(10px);
position:absolute;
top:0;right:0;bottom:0;left:0;
margin:-20px;
}
<div class='box'>
<div class='item'>NYC</div>
</div>
這是你要什麼? https://codepen.io/mcoker/pen/QMpKEa?editors=1100 –
聖潔的狗屎是的。你應該讓它成爲一個答案 – user132522
太棒了!提交了答案:) –