【发布时间】:2015-04-01 09:21:48
【问题描述】:
我正在尝试从 div 中的背景图像中删除溢出。我有 4 个具有相同图像的 div,它们创建了一个背景图像(我定位每个图像,使其在 4 个 div 中匹配)。基本上,我正在尝试将“奇异”图像设置为左侧的动画,并让另一个图像在同一动画中替换它(这实际上只是一个 css 过渡)。问题是 overflow: hidden 隐藏了溢出,但是当您将其移到左侧时,您可以看到该隐藏图像的其余部分。
有什么方法可以剪裁或移除溢出,让我的过渡看起来像一个向左移动的图像?
CSS
.changeOver{
background-repeat: no-repeat;
background-position:130% !important;
-webkit-transition: 2s;
-moz-transition: 2s;
-o-transition: 2s;
transition: 2s;}
脚本
$('#change').click(function () {
$('#fourth').addClass('changeOver');
setTimeout(function(){
$('#fourth').css('background-image', 'none');
}, 5000);
setTimeout(function(){
$('#fourth').css('background-color', 'blue');
}, 1);
setTimeout(function(){
$('#third').addClass('changeOver');
setTimeout(function(){
$('#third').css('background-image', 'none');
}, 5000);
setTimeout(function(){
$('#third').css('background-color', 'blue');
}, 1);
}, 2000);
setTimeout(function(){
$('#second').addClass('changeOver');
setTimeout(function(){
$('#second').css('background-image', 'none');
}, 5000);
setTimeout(function(){
$('#second').css('background-color', 'blue');
}, 1);
}, 4000);
setTimeout(function(){
$('#first').addClass('changeOver');
setTimeout(function(){
$('#first').css('background-image', 'none');
}, 2000);
setTimeout(function(){
$('#first').css('background-color', 'blue');
}, 1);
}, 6000);
});
编辑:Here's the jsfiddle 只需单击标有“是”的按钮
【问题讨论】:
-
欢迎来到 StackOverflow!请务必阅读我们的How to Ask 页面,以帮助您提出一个很好的问题。如果您对您的问题付出一些努力,您更有可能从社区中得到一个好的答案。另外,如果您创建一个 MCVE (stackoverflow.com/help/mcve) 并将其添加到您的问题中,它会有所帮助
标签: javascript jquery html css