调整大小时浮动元素位置(jQuery/CSS)
我有一个隐藏层。当我单击图像时,div 会出现在图像上方。但是,如果在显示 div 时调整页面大小,则图像将随页面元素的其余部分一起移动,但 div 仍保留在其出现的位置。有没有办法让它与图像保持相对关系?
$(".myBox").css({"position":"absolute","width":"400px"});
I have a hidden layer. When I click on an image the div appears over the image. However, if while the div is showing I resize the page, the the image will shift with the rest of the page elements but the div remains in the same place where it appeared. Is there a way to make it stay relative to the image?
$(".myBox").css({"position":"absolute","width":"400px"});
如果我明白你的意思,我想我明白,那么你应该将
position:relative;
放在你的图像上。If I understand what you mean, which I think that I do, then you should just put
position: relative;
on your image.