gpt4 book ai didi

css - 变换 rotateX/rotateY

转载 作者:行者123 更新时间:2023-11-28 08:52:09 26 4
gpt4 key购买 nike

Chrome 版本 39.0.2148.0

我正在尝试在每侧使用 2 张不同的图片来实现翻转图像效果。最初的想法源于http://themestrong.com/demo/argo_wp/ (我也看到了以下问题)在 Chrome 中,第一次翻转似乎有问题。背面图像在第 1 次旋转完全完成之前不显示,然后突然出现。第一次旋转后的每次旋转都很好。我在代码中做错了什么吗?

问题没有出现在 FF 中,这表明代码没问题,我对 Chrome 的态度不够好......

看这里的例子 http://jsfiddle.net/xj33uaph/2/

或在单个 HTML 文件中

<html>
<head>
<title></title>
<style>
#wrap > div {
position:relative
}
#wrap > div img {
display:block;
border:0;
margin:0;
padding:0;
position:absolute;
width:300px;
height:300px
}
#wrap .flip img {
backface-visibility: hidden;
}
#wrap > div {
width:300px;
height:300px
background: none;
perspective: 800px;
transform-style: preserve-3d;
transition: transform 1.5s;
}
#wrap div.flip .img2 {
transform: rotateY(-180deg);
}
#wrap > div.active {
transform: rotateY(-180deg);
}
#wrap > div.active img{
visibility:visible;
}
</style>
<script type="text/javascript">
jQuery(function($){
setInterval(function(){
var imgs = $('#wrap > div:not(.active):has(div.flip)');
var imgs_act = $('#wrap > div.active');
$(imgs[0]).addClass('active');
$(imgs_act[0]).removeClass('active');
},2000);
});
</script>
</head>
<body>
<div id="wrap">
<div class="">
<div class="flip">
<img src="https://farm8.staticflickr.com/7106/7849428998_eed76b378a_n.jpg" alt="img1" class="img2">
<img src="https://farm9.staticflickr.com/8295/7871019630_2ba8536c98_n.jpg" alt="img2" class="img1">
</div>
</div>
</div> <!-- wrap -->
</body>
</html>

最佳答案

这是您重写的样本基 on* this .

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>derp</title>
<style type="text/css">
* {
margin: 0;
padding: 0;
}
/* entire container, keeps perspective */
.flip-container {
perspective: 1000;
}
/* flip the pane when hovered */
.flip-container:hover .flipper,
.flip-container.hover .flipper {
transform: rotateY(180deg);
}
.flip-container, .front, .back {
width: 300px;
height: 300px;
}
/* flip speed goes here */
.flipper {
transition: 0.6s;
transform-style: preserve-3d;
position: relative;
}
/* hide back of pane during swap */
.front, .back {
backface-visibility: hidden;
position: absolute;
top: 0;
left: 0;
}
/* front pane, placed above back */
.front {
z-index: 2;
/* for firefox 31 */
transform: rotateY(0deg);
}
/* back, initially hidden pane */
.back {
transform: rotateY(180deg);
}
.flip-container:hover .flipper,
.flip-container.hover .flipper,
.flip-container.flip .flipper {
transform: rotateY(180deg);
}
</style>
</head>
<body>
<div class="flip-container" ontouchstart="this.classList.toggle('hover');">
<div class="flipper">
<div class="front">
<img src="https://farm8.staticflickr.com/7106/7849428998_eed76b378a_n.jpg">
</div>
<div class="back">
<img src="https://farm9.staticflickr.com/8295/7871019630_2ba8536c98_n.jpg">
</div>
</div>
</div>
<script type="text/javascript">
window.setInterval(function(){
document.getElementsByClassName("flip-container")[0].classList.toggle("flip");
}, 2000);
</script>
</body>
</html>

*我所说的基于,是指复制和粘贴自。

关于css - 变换 rotateX/rotateY,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25810037/

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