gpt4 book ai didi

html - 具有负度数的 CSS rotateY 在 Safari 中不起作用

转载 作者:行者123 更新时间:2023-11-28 03:19:13 25 4
gpt4 key购买 nike

我正在尝试制作沿 Y 轴旋转元素的动画。它适用于 Chrome 和 Firefox,但不适用于 Safari。

我不知道是什么问题,因为正如我之前所说,它在 Chrome、Firefox、Opera 中运行良好...

只在动画中间起作用,其他中间不起作用:(

这是我的代码:

* {
box-sizing: border-box;
}
.book {
position: relative;
width: 200px;
height: 300px;
border: 1px solid black;
}
.book .page {
position: absolute;
width: 50%;
height: 100%;
background: red;
border: 1px solid green;
-webkit-backface-visibility:hidden;
-moz-backface-visibility:hidden;
-o-backface-visibility:hidden;
backface-visibility:hidden;
}
.book .page:nth-child(2n+1) {
left: 0;
transform-origin: right center;
transform: rotateY(-180deg);
}
.book .page:nth-child(2n) {
right: 0;
transform-origin: left center;
transform: rotateY(0deg);
}

.book .page.page-no-1.active {
transform: rotateY(0deg);
}
.book .page.page-no-2.active {
animation: p-2-left 10s;
z-index: 2;
transform: rotateY(-180deg);
}
.book .page.page-no-2.no-active {
animation: p-2-right 10s;
z-index: 3;
transform: rotateY(0deg);
}
.book .page.page-no-3.active {
animation: p-3-left 10s;
z-index: 3;
transform: rotateY(0deg);
}
.book .page.page-no-3.no-active {
animation: p-3-right 10s;
z-index: 2;
transform: rotateY(-180deg);
}
.book .page.page-no-4.active {
animation: p-4-left 10s;
z-index: 4;
transform: rotateY(-180deg);
}
.book .page.page-no-4.no-active {
animation: p-4-right 10s;
z-index: 2;
transform: rotateY(0deg);
}
.book .page.page-no-5.active {
animation: p-5-left 10s;
z-index: 5;
transform: rotateY(0deg);
}
.book .page.page-no-5.no-active {
animation: p-5-right 10s;
z-index: 4;
transform: rotateY(-180deg);
}

@keyframes p-5-left {
0% { transform: rotateY(-180deg); z-index: 4; }
49% { z-index: 4; }
50% { z-index: 5; }
100% { transform: rotateY(0deg); z-index: 5; }
}
@keyframes p-4-left {
0% { transform: rotateY(0deg); z-index: 5; }
49% { z-index: 5; }
50% { z-index: 4; }
100% { transform: rotateY(-180deg); z-index: 4; }
}
@keyframes p-3-left {
0% { transform: rotateY(-180deg); z-index: 2; }
49% { z-index: 2; }
50% { z-index: 3; }
100% { transform: rotateY(0deg); z-index: 3; }
}
@keyframes p-2-left {
0% { transform: rotateY(0deg); z-index: 3; }
49% { z-index: 3; }
50% { z-index: 2; }
100% { transform: rotateY(-180deg); z-index: 2; }
}

@keyframes p-5-right {
0% { transform: rotateY(0deg); z-index: 5; }
49% { z-index: 5; }
50% { z-index: 4; }
100% { transform: rotateY(-180deg); z-index: 4; }
}
@keyframes p-4-right {
0% { transform: rotateY(-180deg); z-index: 4; }
49% { z-index: 4; }
50% { z-index: 5; }
100% { transform: rotateY(0deg); z-index: 5; }
}
@keyframes p-3-right {
0% { transform: rotateY(0deg); z-index: 3; }
49% { z-index: 3; }
50% { z-index: 2; }
100% { transform: rotateY(-180deg); z-index: 2; }
}
@keyframes p-2-right {
0% { transform: rotateY(-180deg); z-index: 2; }
49% { z-index: 2; }
50% { z-index: 3; }
100% { transform: rotateY(0deg); z-index: 3; }
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="book">
<div class="page page-no-5">Página 5</div>
<div class="page page-no-6">Página 6</div>
<div class="page page-no-3">Página 3</div>
<div class="page page-no-4">Página 4</div>
<div class="page page-no-1 active">Página 1</div>
<div class="page page-no-2">Página 2</div>
</div>
<button onclick="jQuery('.page-no-2, .page-no-3').removeClass('no-active').addClass('active')">Go up to page 3</button>
<button onclick="jQuery('.page-no-4, .page-no-5').removeClass('no-active').addClass('active')">Go up to page 6</button><br>
<button onclick="jQuery('.page-no-2, .page-no-3').removeClass('active').addClass('no-active')">Go down to page 1</button>
<button onclick="jQuery('.page-no-4, .page-no-5').removeClass('active').addClass('no-active')">Go down to page 3</button>

JSFIDDLE link

最佳答案

好吧,我认为问题不在于 Safari 中的 z-index。 Safari 中的问题在于 transform: rotateY(-Xdeg) 和负度数。

如果我将第 3 页和第 5 页中的 -180deg 更改为 180 度,它在 Safari 中效果很好。

* {
box-sizing: border-box;
}
.book {
position: relative;
width: 200px;
height: 300px;
border: 1px solid black;
}
.book .page {
position: absolute;
width: 50%;
height: 100%;
background: red;
border: 1px solid green;
-webkit-backface-visibility:hidden;
-moz-backface-visibility:hidden;
-o-backface-visibility:hidden;
backface-visibility:hidden;
}
.book .page:nth-child(2n+1) {
left: 0;
transform-origin: right center;
transform: rotateY(180deg);
}
.book .page:nth-child(2n) {
right: 0;
transform-origin: left center;
transform: rotateY(0deg);
}

.book .page.page-no-1.active {
transform: rotateY(0deg);
}
.book .page.page-no-2.active {
animation: p-2-left 10s;
z-index: 2;
transform: rotateY(-180deg);
}
.book .page.page-no-2.no-active {
animation: p-2-right 10s;
z-index: 3;
transform: rotateY(0deg);
}
.book .page.page-no-3.active {
animation: p-3-left 10s;
z-index: 3;
transform: rotateY(0deg);
}
.book .page.page-no-3.no-active {
animation: p-3-right 10s;
z-index: 2;
transform: rotateY(-180deg);
}
.book .page.page-no-4.active {
animation: p-4-left 10s;
z-index: 4;
transform: rotateY(-180deg);
}
.book .page.page-no-4.no-active {
animation: p-4-right 10s;
z-index: 2;
transform: rotateY(0deg);
}
.book .page.page-no-5.active {
animation: p-5-left 10s;
z-index: 5;
transform: rotateY(0deg);
}
.book .page.page-no-5.no-active {
animation: p-5-right 10s;
z-index: 4;
transform: rotateY(-180deg);
}

@keyframes p-5-left {
0% { transform: rotateY(180deg); z-index: 4; }
49% { z-index: 4; }
50% { z-index: 5; }
100% { transform: rotateY(0deg); z-index: 5; }
}
@keyframes p-4-left {
0% { transform: rotateY(0deg); z-index: 5; }
49% { z-index: 5; }
50% { z-index: 4; }
100% { transform: rotateY(-180deg); z-index: 4; }
}
@keyframes p-3-left {
0% { transform: rotateY(180deg); z-index: 2; }
49% { z-index: 2; }
50% { z-index: 3; }
100% { transform: rotateY(0deg); z-index: 3; }
}
@keyframes p-2-left {
0% { transform: rotateY(0deg); z-index: 3; }
49% { z-index: 3; }
50% { z-index: 2; }
100% { transform: rotateY(-180deg); z-index: 2; }
}

@keyframes p-5-right {
0% { transform: rotateY(0deg); z-index: 5; }
49% { z-index: 5; }
50% { z-index: 4; }
100% { transform: rotateY(180deg); z-index: 4; }
}
@keyframes p-4-right {
0% { transform: rotateY(-180deg); z-index: 4; }
49% { z-index: 4; }
50% { z-index: 5; }
100% { transform: rotateY(0deg); z-index: 5; }
}
@keyframes p-3-right {
0% { transform: rotateY(0deg); z-index: 3; }
49% { z-index: 3; }
50% { z-index: 2; }
100% { transform: rotateY(180deg); z-index: 2; }
}
@keyframes p-2-right {
0% { transform: rotateY(-180deg); z-index: 2; }
49% { z-index: 2; }
50% { z-index: 3; }
100% { transform: rotateY(0deg); z-index: 3; }
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="book">
<div class="page page-no-5">Página 5</div>
<div class="page page-no-6">Página 6</div>
<div class="page page-no-3">Página 3</div>
<div class="page page-no-4">Página 4</div>
<div class="page page-no-1 active">Página 1</div>
<div class="page page-no-2">Página 2</div>
</div>
<button onclick="jQuery('.page-no-2, .page-no-3').removeClass('no-active').addClass('active')">Go up to page 3</button>
<button onclick="jQuery('.page-no-4, .page-no-5').removeClass('no-active').addClass('active')">Go up to page 6</button><br>
<button onclick="jQuery('.page-no-2, .page-no-3').removeClass('active').addClass('no-active')">Go down to page 1</button>
<button onclick="jQuery('.page-no-4, .page-no-5').removeClass('active').addClass('no-active')">Go down to page 3</button>

关于html - 具有负度数的 CSS rotateY 在 Safari 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45289869/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com