製品コンフィギュレーターを構築しています。重ねるには2枚の画像が必要です。ストーブ自体が 1 つのイメージであり、ノブ/ハンドルが別のイメージであるストーブを想像してみてください。
両方の画像は同じサイズなので、「完全に」重なる必要があります。どちらの画像も div 内にあり、必要に応じて div.append(Child) を返す関数に基づいています。
オンラインで見つけたすべての方法を試しましたが、正しいと思うことを実行しましたが、明らかにうまくいきません. 1 つの div を呼び出してからもう 1 つ (img1img2) を呼び出すと、重複しません。最初の div 内で 2 番目の画像を呼び出すと、表示されません。私は何を間違っていますか?! html:
<input type="button" onclick="create_img(); " value="Create image" />
<div class="imageWrapper">
<div id="pop" >
<div id="pop2" >
</div>
</div>
</div>
JS:
function create_img(){
var im=""
var div = document.getElementById("pop");
var hold= document.createElement("img");
if (document.Lacanche_Configurator.Range.value=="1" && document.Lacanche_Configurator.Range_color.value=="12" ){im= "http://www.french-barn.com/configurator/img_front/cormatin/jauneprovence.jpg" ;}
else if (document.Lacanche_Configurator.Range.value=="1" && document.Lacanche_Configurator.Range_color.value=="13" ){im= "http://www.french-barn.com/attachments/Image/Lacanche/Ranges_front/Chagny1800-trans.png" ;}
else {im="http://technofriends.files.wordpress.com/2008/03/google_logo_.jpg";}
hold.src=im;
hold.border=0;
div.appendChild(hold);
var im2=""
var div = document.getElementById("pop2");
var hold= document.createElement("img");
if (document.Lacanche_Configurator.Finishes.value=="1" ){im2= "http://www.french-barn.com/configurator/img_front/cormatin/laitonbrillant.png" ;}
else {im2="http://technofriends.files.wordpress.com/2008/03/google_logo_.jpg";}
hold.src=im2;
hold.border=0;
div.appendChild(hold);
}
CSS:
.imageWrapper{
position: relative;
top:0;
left:0;
width:160px;
}
#pop {
background:transparent;
}
#pop2 {
position: absolute;
left:0;
top: -150px;
background:transparent;
}
私は非常に多くの方法を試しましたが、次に何をすべきかわかりません!!
ありがとうございました!