我有兩個不同的圖像,我互相堆疊在一起。 .image-1是背景圖像,.image-2是前景圖像。我想要這樣,因爲前景圖像是一個包含整個裏面的PNG文件。當你看完整個你看到的背景圖像的一部分。我希望能夠通過JQuery中的可拖動來移動背景圖片。這是行不通的,因爲我不能觸摸背景層,因爲它被前景層覆蓋。這是我的源代碼:通過DRAGGABLE在另一個DIV下移動一個DIV?(CSS,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({ });
});
,但沒有奏效。
參考這個問題是,你想要什麼 http://stackoverflow.com/questions/11271704/jquery-drag-div-css-background。 – 2015-04-05 21:47:47