我正在制作一个相当简单的网站,有几个相当简单的 CSS 动画。例如,我的网站上有一个“喜欢”按钮,人们可以在其中喜欢评论。当人们点击“喜欢”按钮时,“心”会自行变形并缩放 2 倍,并且具有平滑的过渡。
在 Chrome 和 Firefox 上的桌面上一切都运行得很好,但当我在 iOS 上(在我的 iPhone 15 Pro Max 上)尝试时,它非常慢、滞后且无法使用。
我还有一个带有一些奇特 CSS 关键帧的提交按钮,这些关键帧使小星星在提交按钮内移动以使其美观,虽然该按钮的动画并不滞后,但 iOS 上的星星完全脱离了容器,在 iOS 上超出了其他元素,而在桌面上一切都很好。
超级令人沮丧!
我要求 chatgpt 帮助我为 iOS 进行 webkit 查询,在 Google 上尝试了一些方法,但没有任何效果。老实说,我相信 chatgpt 给我的完全是无稽之谈,这就是为什么我来这里寻求帮助。
.btn {
margin-top: 1rem;
margin-bottom: 1rem;
display: flex;
justify-content: center;
align-items: center;
width: 13rem;
overflow: hidden;
height: 3rem;
background-size: 300% 300%;
backdrop-filter: blur(1rem);
border-radius: 5rem;
transition: 0.5s;
animation: gradient_301 5s ease infinite;
border: double 4px transparent;
background-image: linear-gradient(#212121, #212121), linear-gradient(137.48deg, #ffdb3b 10%,#FE53BB 45%, #8F51EA 67%, #0044ff 87%);
background-origin: border-box;
background-clip: content-box, border-box;
}
#container-stars {
position: absolute;
z-index: -1;
width: 100%;
height: 100%;
overflow: hidden;
transition: 0.5s;
backdrop-filter: blur(1rem);
border-radius: 5rem;
}
strong {
z-index: 2;
font-family: 'Oooh Baby', cursive;
font-size: 22px;
letter-spacing: 5px;
color: #FFFFFF;
text-shadow: 0 0 4px white;
}
#glow {
position: absolute;
display: flex;
width: 12rem;
}
.circle {
width: 100%;
height: 30px;
filter: blur(2rem);
animation: pulse_3011 4s infinite;
z-index: -1;
}
.circle:nth-of-type(1) {
background: rgba(254, 83, 186, 0.636);
}
.circle:nth-of-type(2) {
background: rgba(142, 81, 234, 0.704);
}
.btn:hover #container-stars {
z-index: 1;
background-color: #212121;
}
.btn:hover {
transform: scale(1.1);
cursor: pointer;
}
.btn:active {
border: double 4px #FE53BB;
background-origin: border-box;
background-clip: content-box, border-box;
transition: 0.1s;
transform: scale(1.4);
animation: none;
}
.btn:active .circle {
background: #FE53BB;
}
#stars {
position: relative;
background: transparent;
width: 200rem;
height: 200rem;
}
#stars::after {
content: "";
position: absolute;
top: -10rem;
left: -100rem;
width: 100%;
height: 100%;
animation: animStarRotate 90s linear infinite;
}
#stars::after {
background-image: radial-gradient(#ffffff 1px, transparent 1%);
background-size: 50px 50px;
}
#stars::before {
content: "";
position: absolute;
top: 0;
left: -50%;
width: 170%;
height: 500%;
animation: animStar 60s linear infinite;
}
#stars::before {
background-image: radial-gradient(#ffffff 1px, transparent 1%);
background-size: 50px 50px;
opacity: 0.5;
}
@keyframes animStar {
from {
transform: translateY(0);
}
to {
transform: translateY(-135rem);
}
}
@keyframes animStarRotate {
from {
transform: rotate(360deg);
}
to {
transform: rotate(0);
}
}
@keyframes gradient_301 {
0% {
background-position: 0% 50%;
}
50% {
background-position: 100% 50%;
}
100% {
background-position: 0% 50%;
}
}
@keyframes pulse_3011 {
0% {
transform: scale(0.75);
box-shadow: 0 0 0 0 rgba(0, 0, 0, 0.7);
}
70% {
transform: scale(1);
box-shadow: 0 0 0 10px rgba(0, 0, 0, 0);
}
100% {
transform: scale(0.75);
box-shadow: 0 0 0 0 rgba(0, 0, 0, 0);
}
}
.heart {
width: 30px;
margin: 0;
transition: 0.4s;
}
.heart:hover {
transition: 0.1s;
cursor: pointer;
transform: scale(1.5);
}
.heart:active {
transition: 0.3s;
transform: scale(3.7);
opacity: 0.1;
}
<button class="btn" type="button">
<strong>Submit</strong>
<div id="container-stars">
<div id="stars"></div>
</div>
<div id="glow">
<div class="circle"></div>
<div class="circle"></div>
</div>
</button>
<img src="https://images.emojiterra.com/google/noto-emoji/unicode-15/color/512px/2764.png" class="heart">
我找到了这种缓慢的原因。这是 noto-emoji 字体。如果您不使用它,您的网站应该可以正常工作。
如果您需要使用 noto 表情符号,我还没有找到解决方案。但你可以在这里看到更多:
Google Noto 彩色字体使应用程序在 Safari Webkit (IOS/MacOS) 上速度极慢,但在 MacOS Chrome 上却不然