Hi, I am having problems centrally aligning an image. The basic HTML is shown below. I have taken out other elements that are not effecting this problem:
<div id="ImagePlaceholder">
<div id="Images">
<img class="current" src="photo1.jpg" alt="" />
<img class="nextimage" src="" alt="" />
</div>
</div>
and the CSS is:
#ImagePlaceholder {
margin: 1.5% 2% 1% 2%;
height: 70%;
width: 96%;
background-color: #333;
display: block;
}
#Images{
position:relative;
height: 100%;
max-width: 100%; <!-- 100px -->
margin: auto;
}
#Images img {
display: block;
position: absolute;
max-width: 100%;
height: 100%;
margin: auto;
}
Image placeholder is contained within a static div, with the option to go absolute for a full screen effect of its parent div hence the percentage values rather than em or px. I have been stuck on this problem for some hours now and can't find a fix on google. The code does kind of work if max-width of #Images is in px but it is never exactly in the centre and the value required would have to change for every image. When max-width of #Images is in a percentage it always aligns to the left.
Finally, it was working when the images were stored in a list, but had to change html accordingly as it is undesirable to load 20-30 images before the page can be used. (It is a page with thumbnails loaded into the next image img so that it can fade between them. I have all the jquery for this working so would like to avoid changing the html too much.
Any insight or help is much appreciated.