z-index
どの画像が一番上にあるかを判断するために使用しposition:absolute
ます。また、画像が重なるように1つの画像に表示することもできます。
しかし、ここには多くのアプローチがあります。これを試してください:http://jsfiddle.net/N6rjG/
そこで、Tシャツをdivの背景にし、選択した画像をその中に入れます。スクリプトはすでに存在し、単純です。
html:
<!-- This one will be the tshirt--->
<div id="tshirt">
</div>
<h1>Click on Image to Select Design</h1>
<!--the choices-->
<img id="d1" class="d" src="https://encrypted-tbn2.google.com/images?q=tbn:ANd9GcQUomLjtjuA81HKgj48ZaIT6Uvd9JGttmUvVcFO3j3ytp6v6MV0" />
<img id="d2" class="d" src="http://www.ironman2.net/iron-man.jpg" />
<img class="d" src="http://www.unc.edu/~bhamidi/personal/naruto.jpg" />
CSS:
#tshirt{
float:left;
width:390px;
height:400px;
background:url(http://www.schumacher-fanclub.com/media/SFR1119-ferrari-t-shirt-small-scudetto-red.jpg);
}
.d{
width:100px;
height:130px;
cursor:pointer;
}
脚本:
$('img').click(function(){
$("#tshirt").html(' ');
$(this).clone()
.appendTo("#tshirt")
.css({margin:'130px 0 0 150px'});
});