我想使用 HTML 和纯 javascript 在大图像上嵌入小图像。它在 Chrome 和 Firefox 中运行。但它在 IE 8 中不起作用。我按照http://www.w3schools.com/cssref/pr_pos_z-index.asp中的建议使用了 z-index:-1 。任何人都可以帮助代码片段吗?
请找到示例代码片段,它适用于 Chrome、Safari、Firefox,但不适用于 IE8
<html>
<head>
<title>Image over Image</title>
<script type="text/javascript">
function loadIMG(){
var backgroundIMG = document.getElementById("bigIMG");
var boundObject = backgroundIMG.getBoundingClientRect();
var img = document.getElementById("smallIMG");
img.style.top = (boundObject.top + (boundObject.height * 0.2))+"px";
img.style.left = (boundObject.left + (boundObject.width * 0.2))+"px";
img.style.height = (boundObject.height * 0.6)+"px";
img.style.width = (boundObject.width *0.6)+"px";
img.style.position = "absolute";
img.style.display = "inline";
}
</script>
</head>
<body onclick="loadIMG();">
<center><h1>Image on Image</h1>
<h6>Click on the page to embed small image on big image</h6></center>
<img id="bigIMG" src="http://www.sxc.hu/pic/m/t/tu/tulsaeupho/1206951_blue_flowers_splatter_and_swirls_background_set_1.jpg">
<img id="smallIMG" src="http://i52.photobucket.com/albums/g14/1kevinm/small_unittus_sm_icon.png" style="display:none">
</body>
</html>
提前致谢