过渡期间闪烁的固定背景

时间:2013-11-05 03:21:32

标签: css3 transition fixed flicker translate3d

我在转换过程中遇到固定背景问题。我有2个面板,面板-1有2个图像,分别从左到右和从右到左动画,基本上它只会添加一个类'animate'来触发转换。在过渡期间,面板-2(具有固定背景和一些文本内容)将在chrome中闪烁。请实时查看http://jsfiddle.net/7EqaV/embedded/result/

有什么建议吗?在此先感谢!..

HTML code:

<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');
    });
});

1 个答案:

答案 0 :(得分:0)

Heello!

尝试使用此css:

-webkit-backface-visibility: hidden;
/*  will not work for sprites and image backgrounds */

body {-webkit-transform:translate3d(0,0,0);}
/* screws up backgrounds that are tiled  */

我想你要创建一个名为noflick的课程,这个css

.noflick{-webkit-transform:translate3d(0,0,0);}

我希望这会对你有所帮助。