我不擅长css,我已经花了很多时间来做这件事,我想将一个固定/动态大小的div居中。就像是
<div>
// Imagine to have a multiple images here, size is 100x100.
// When I click on the image (I am using jquery for this), #fade will appear and a window
// that contain the original size of the image.
<img class="picture" src="picture.jpg" width="100" height=100"/>
</div>
<div id="fade"></div>
<div class="imgWindow">
<img src="picture.jpg"/> // original size
</div>
css
#fade {
display: none;
background: black;
opacity:0.4;
filter:alpha(opacity=50);
z-index: 10;
position: fixed;
left: 0; top: 0;
width: 100%; height: 100%;
}
.imgWindow {
width: 640px;
height: 422px;
background: white;
position: fixed;
margin-left: 10%;
margin-top: 5%;
z-index: 11;
left: 0; top: 0;
}
即使我重新调整浏览器窗口的大小,图像窗口也应该居中。请帮忙,谢谢!