我正在尝试使用jquery和css3创建翻页。如果我将2个页面放在1个容器中然后旋转整个容器,我就可以这样做,但我想只旋转我的页面。这是我的代码:
的CSS:
#pagecontainer {
position: absolute;
width: 100%;
height: 100%;
}
.page {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
-o-backface-visibility: hidden;
backface-visibility: hidden;
}
.back {
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
-o-transform: rotateY(180deg);
transform: rotateY(180deg);
}
.flip.out {
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
-ms-transform: rotateY(180deg);
-o-transform: rotateY(180deg);
transform: rotateY(180deg);
-webkit-transform-style: preserve-3d;
-webkit-transition: all 1.0s linear;
-moz-transform-style: preserve-3d;
-moz-transition: all 1.0s linear;
-o-transform-style: preserve-3d;
-o-transition: all 1.0s linear;
transform-style: preserve-3d;
transition: all 1.0s linear;
}
.flip.in {
-webkit-transform: rotateY(0deg);
-moz-transform: rotateY(0deg);
-ms-transform: rotateY(0deg);
-o-transform: rotateY(0deg);
transform: rotateY(0deg);
-webkit-transform-style: preserve-3d;
-webkit-transition: all 1.0s linear;
-moz-transform-style: preserve-3d;
-moz-transition: all 1.0s linear;
-o-transform-style: preserve-3d;
-o-transition: all 1.0s linear;
transform-style: preserve-3d;
transition: all 1.0s linear;
}
然后我将这些类添加到pagecontainer中的页面中:
container.append(nextPage);
nextPage.attr("class", "page back");
currentPage.one('webkitTransitionEnd', function(e) {
currentPage.remove();
});
nextPage.attr("class", "page back flip in");
container[0].offsetWidth;
currentPage.attr("class", "page flip out");
但只有正面在翻转?我做错了什么?
修改 解决了它。我需要将脚本中的顺序更改为:
currentPage.attr("class", "page flip out"); <-- Start with this
container[0].offsetWidth;
nextPage.attr("class", "page back flip in"); <-- Finish with this
答案 0 :(得分:0)
看看这个插件及其源代码http://tympanus.net/codrops/2012/09/03/bookblock-a-content-flip-plugin/ 请记住,即使IE10也不支持preserve-3d