我有图像(#myimage),它们的图像高度不同。还有一个覆盖层(# over ),它应该正好覆盖在这张图像上。我已经将覆盖设置为100%,这对我不起作用,因为还有一些不应该从覆盖层中覆盖的东西。
问题是,如果我不知道这个高度是多少,我如何确定#myimage的图像高度?不过,它应该在高度上有所变化。所以宽度是100%,高度是自动的。
<div id="container">
<img id="myimage" src="image.png">
<div id="overlay">
<img src="overlay.png">
</div>
<div id="someotherstuff">
// some other stuff not to cover
</div>
</div>css
#myimage {width:100%;height:auto;}
#overlay { position: absolute; top: 0; left: 0; height: 100%; width: 100%;}发布于 2014-10-20 15:37:00
使用jquery执行此操作:
$(document).ready(function(){
image_height = $("#myimage").height();
$("#overlay").height(image_height);
});https://stackoverflow.com/questions/26469451
复制相似问题