在过渡期间,我的固定背景有问题。我有 2 个面板,面板 1 有 2 个图像,它们将分别从左到右和从右到左进行动画处理,基本上它只会添加一个“动画”类来触发过渡。在过渡期间,panel-2(具有固定背景和一些文本内容)将以 chrome 闪烁。请现场查看http://jsfiddle.net/7EqaV/embedded/result/
有什么建议吗?提前致谢!..
HTML 代码:
<div class="wrapper">
<input type="button" value='animate' id="animate" />
<div class="panel-1">
<div class="items" id="slideLeft">
<img src="http://sitetest12302.businesscatalyst.com/images/p1.jpg">
</div>
<div class="items" id="slideRight">
<img src="http://sitetest12302.businesscatalyst.com/images/p2.jpg">
</div>
</div>
<div class="panel-2">
<div class="bg"></div>
<div class="content">
<h1>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna</h1>
</div>
</div>
CSS 代码:
.wrapper {
width:500px;
margin:auto;
}
.panel-1, .panel-2 {
width:100%;
height: 200px;
border: 2px solid #000;
position:relative;
}
.panel-2 .bg {
width:100%;
height: 200px;
background:url(http://sitetest12302.businesscatalyst.com/images/bg.jpg) no-repeat;
background-size:cover;
background-attachment: fixed;
position: absolute;
background-position:center;
}
.items {
width:150px;
height:150px;
}
.content {
position:absolute;
z-index:2;
width:100%;
}
h1 {
filter:alpha(opacity=0);
-moz-opacity:0;
opacity: 0;
transition: opacity 1s ease-in-out;
-moz-transition: opacity 1s ease-in-out;
color:#FFF;
font-size:15px;
}
#slideLeft, #slideRight {
-webkit-transition:-webkit-transform 1s 0s;
-moz-transition: -moz-transform 1s 0s;
width:150px;
height:150px;
}
#slideLeft {
float:left;
-webkit-transform:translate3d(-200%, 0, 0);
-moz-transform:translate3d(-200%, 0, 0);
}
#slideRight {
float:right;
-webkit-transform:translate3d(200%, 0, 0);
-moz-transform:translate3d(200%, 0, 0);
}
.animate #slideLeft, .animate #slideRight {
-webkit-transform:translate3d(0, 0, 0);
-moz-transform:translate3d(0, 0, 0);
}
.animate h1 {
filter:alpha(opacity=100) !important;
-moz-opacity:1 !important;
opacity: 1 !important;
}
JS代码:
$(document).ready(function () {
$('input#animate').click(function () {
$('.panel-1, .panel-2').toggleClass('animate');
});
});