我正在尝试通过SVG(如Instagram故事)获得粘糊糊的效果。
Chrome的功能还不错,但在Safari和iOS上看起来很奇怪。
在Chrome上的外观:
及其在Safari中的外观:
问题是拐角处的边界半径有时会丢失,另一个圆会凸出。在chrome上,这都不是问题。
<main>
<section class="section-2-b">
<div class="wrapper-a">
<h1 id="left-align-text">
<div class="goo" contenteditable="true"> This <br> is an example <br> of a simple headline <br> or text </div>
</h1>
<br> <br>
<h1 id="left-align-text">
<div class="goo" contenteditable="true"> This <br> is an example <br> </div>
</h1>
<!-- Filter: https://css-tricks.com/gooey-effect/ -->
<svg style="visibility: hidden; position: absolute;" width="0" height="0" xmlns="http://www.w3.org/2000/svg" version="1.1">
<defs>
<filter id="goo"><feGaussianBlur in="SourceGraphic" stdDeviation="3" result="blur" />
<feColorMatrix in="blur" mode="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 18 -9" result="goo" />
<feComposite in="SourceGraphic" in2="goo" operator="atop"/>
</filter>
</defs>
</svg>
</div>
</section>
<section class="section-1-a">
<div class="wrapper-b">
<h1 id="center-align-text">
<div class="goo" contenteditable="true">This <br> is an example <br> of a simple headline <br> or text <br> with rounded <br> corners <br> a gooey filter. <br> cool </div>
</h1>
<!-- Filter: https://css-tricks.com/gooey-effect/ -->
<svg style="visibility: hidden; position: absolute;" width="0" height="0" xmlns="http://www.w3.org/2000/svg" version="1.1">
<defs>
<filter id="goo"><feGaussianBlur in="SourceGraphic" stdDeviation="3" result="blur" />
<feColorMatrix in="blur" mode="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 19 -9" result="goo" />
<feComposite in="SourceGraphic" in2="goo" operator="atop"/>
</filter>
</defs>
</svg>
</div>
</section>
</main>
:root {
--color-bg: black;
--color-bg2: white;
--color-highlight: red;
--font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}
*, body, main, div, img {
margin: 0;
padding: 0;
max-width: 100% !important;
}
html, body {
width: 100%;
height: 100%;
overflow-x: hidden;
}
main {
max-width: 100% !important;
}
.wrapper-a{
background: url("https://66.media.tumblr.com/5be0d33c4e6d9f0bdfdad71c01973c70/tumblr_pomsixQ9pG1xmzftzo3_r1_1280.jpg") center;
background-size:cover;
height:100vh;
padding:5rem;box-sizing:border-box;}
.wrapper-b{
background: url("https://66.media.tumblr.com/ad7c69e0ce19df9cb26aad0b126b943e/tumblr_plj87sq87s1xmzftzo1_1280.jpg") center;
background-size:cover;
height:200vh;
padding:5rem;box-sizing:border-box;}
#center-align-text{ color:white; text-align: -webkit-center;}
#left-align-text { color:white; }
.goo {
font-size: 2rem;
line-height: 1.35;
display: inline;
box-decoration-break: clone;
background: var(--color-highlight);
padding: 0.5rem 1.2rem;
filter: url('#goo');
}
.goo:focus {
outline: 0;
}
body {
//padding: 7.5vh 100px 0 100px;
font-family: var(--font);
//background: url("https://66.media.tumblr.com/feffda2237b778e5f9a697693478b196/tumblr_pu1apbcqeS1xmzftzo2_1280.jpg") center;
//background-size:cover;;
}
在Safari和Ios上解决此问题的宝贵帮助: