CSS Will-Crange break on safari

发布于 2025-01-31 15:58:51 字数 1892 浏览 1 评论 0原文

如果我将will-change:opacity;属性应用于固定的边框Radious的元素,这将破坏CSS,而不考虑溢出和半径。

它只是在Safari上发生,其他浏览器还可以。

.card{
    border-radius: 80px;
    height: 200px;
    width: 200px;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
}

.bg-image{
    position: absolute;
    width: auto;
    height: 100%;
    display: block;
    z-index: 1;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    will-change: opacity; // => COMMENT HERE and it's works
}

.card--content{
    z-index: 30;
    position: relative;
    top: 40%;
    height: 60%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    box-sizing: border-box;
}

.card::before{
    content: '';
    display: block;
    position: absolute;
    bottom: 0;
    height: 0;
    width: 100%;
    background-color: white;
    z-index: 20;
    will-change: height;
    transition: height 0.24s ease-in-out;
}

.card::after{
    content: '';
    display: block;
    position: absolute;
    bottom: 0;
    height: 100%;
    width: 100%;
    z-index: 10;
    background: linear-gradient(180.49deg, rgba(136, 168, 187, 0.217) 40.63%, rgba(0, 122, 194, 0.7) 71.44%);
    opacity: 1;
    transition: opacity 0.25s linear;
}
    
.card:hover::after{
  opacity: 0;
}
<div class="card">
  <img class="bg-image lazy entered loaded" data-src="https://dummyimage.com/600 x 600/cfcfcf/fff.png" aria-label="" data-ll-status="loaded" src="https://dummyimage.com/600 x 600/cfcfcf/fff.png">
  <div class="card--content">
  content
  </div>
</div>

有人有同样的问题吗? 谢谢

if I apply the will-change: opacity;property to my element with a fixed value of border radious, this will broke the css and not consider the overflow and the radius.

it just happens on Safari, the other browsers are ok.

.card{
    border-radius: 80px;
    height: 200px;
    width: 200px;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
}

.bg-image{
    position: absolute;
    width: auto;
    height: 100%;
    display: block;
    z-index: 1;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    will-change: opacity; // => COMMENT HERE and it's works
}

.card--content{
    z-index: 30;
    position: relative;
    top: 40%;
    height: 60%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    box-sizing: border-box;
}

.card::before{
    content: '';
    display: block;
    position: absolute;
    bottom: 0;
    height: 0;
    width: 100%;
    background-color: white;
    z-index: 20;
    will-change: height;
    transition: height 0.24s ease-in-out;
}

.card::after{
    content: '';
    display: block;
    position: absolute;
    bottom: 0;
    height: 100%;
    width: 100%;
    z-index: 10;
    background: linear-gradient(180.49deg, rgba(136, 168, 187, 0.217) 40.63%, rgba(0, 122, 194, 0.7) 71.44%);
    opacity: 1;
    transition: opacity 0.25s linear;
}
    
.card:hover::after{
  opacity: 0;
}
<div class="card">
  <img class="bg-image lazy entered loaded" data-src="https://dummyimage.com/600 x 600/cfcfcf/fff.png" aria-label="" data-ll-status="loaded" src="https://dummyimage.com/600 x 600/cfcfcf/fff.png">
  <div class="card--content">
  content
  </div>
</div>

someone had the same problem?
thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

赤濁 2025-02-07 15:58:51

我找到了一个解决方案,但我认为不是最好的。但是目前是我找到的最好的解决方案。希望有人找到更好的一个。

我正在使用

-webkit-mask-image:-webkit-radial-gradient(white, black);
        mask-image:-webkit-radial-gradient(white, black);

I find a solution but I don't think is the best. But for now is the best solution that i found. Hope someone find a better one.

i'm using

-webkit-mask-image:-webkit-radial-gradient(white, black);
        mask-image:-webkit-radial-gradient(white, black);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文