2013-11-15 150 views
2

我一直沒有能夠找到谷歌上的任何東西,但它可以改變一個背景網址的順序與jquery懸停/點擊/任何?jQuery的移動背景圖像在css3多個背景圖像的順序?

即此:

background: 
    url('1st_bg.png') no-repeat center; 
    url('2nd_bg.png') no-repeat center; 
    url('3rd_bg.png') no-repeat center; 

到這一點?

background: 
    url('3rd_bg.png') no-repeat center; 
    url('2nd_bg.png') no-repeat center; 
    url('1st_bg.png') no-repeat center; 

使用jquery?

我似乎無法弄清楚如何走動我的CSS ..任何幫助將是非常讚賞:-)

回答

1

看看這個:DEMO

HTML

<body class="image" id="BODY"> 
<button id="changeOrder" style="position:absolute;bottom:100px;left:100px">CHANGE IMAGE ORDER</button> 
</body> 

CSS

.image { 
background: url(http://radiantq.com/wp-content/uploads/2011/11/software_box.png) no-repeat 10px 10px, url(http://www.hdwallpapers3d.com/wp-content/uploads/2013/04/Flower-wallpaper-29.jpg) no-repeat 90px 90px, url(http://3.bp.blogspot.com/-kEDW4tNSmpA/UYnb_TbNiqI/AAAAAAAAKlc/MuZ3D0k6xRs/s1600/wallpapers-of-Rose-Flower456.jpg) no-repeat 180px 180px; 
background-size:100px 100px; 
width:500px; 
height: 500px; 
} 
.change { 
background:url(http://www.hdwallpapers3d.com/wp-content/uploads/2013/04/Flower-wallpaper-29.jpg) no-repeat 10px 10px, url(http://radiantq.com/wp-content/uploads/2011/11/software_box.png) no-repeat 90px 90px, url(http://3.bp.blogspot.com/-kEDW4tNSmpA/UYnb_TbNiqI/AAAAAAAAKlc/MuZ3D0k6xRs/s1600/wallpapers-of-Rose-Flower456.jpg) no-repeat 180px 180px; 
background-size:100px 100px; 
width:500px; 
height: 500px; 
} 

jQuery腳本

$("#changeOrder").click(function() { 
$('#BODY').addClass('change'); 
});