【发布时间】:2015-04-05 21:14:28
【问题描述】:
我有两个不同的图像,我将它们堆叠在一起。 .image-1 是背景图片,.image-2 是前景图片。我想要这样,因为前景图像是一个包含整个内部的 PNG 文件。当您查看整个图像时,您会看到背景图像的一部分。我希望能够通过 JQuery 中的可拖动来移动背景图像。这不起作用,因为我无法触摸背景层,因为它被前景层覆盖。这是我的源代码:
CSS
.image-1
{
z-index: 0;
position: absolute;
background-image: url("image_1.png");
width: 400px;
height: 400px;
background-repeat: no-repeat;
background-position: center;
}
.image-2
{
z-index: 1;
position: absolute;
background-image: url("image_2.png");
width: 400px;
height: 400px;
background-repeat: no-repeat;
background-position: center;
}
HTML
<div class="image-1"></div>
<div class="image-2"></div>
JQuery
$(".image-1").draggable({});
如何通过可拖动访问背景 div,但仍将我移动的图像保留在背景中?
已编辑:
我试过这样:
$("#image-2").mousedown(function(event)
{
$("#image-1").draggable({ });
});
但它不起作用。
【问题讨论】:
-
参考这个问题是你想要的stackoverflow.com/questions/11271704/…。
标签: javascript jquery css html