Quote:
Originally Posted by swepub
I used your 2nd one and it works great. Just one more question - can you adjust the space between the images and center the two images?
|
Yes, just set the margin to auto and define a specific width for the div: width = image(s) + padding
5+200+5 + 5+200+5 = 420px
Code:
CSS
.images {clear:both; width:420px; margin:0 auto}
.images img {float:left; width:200px; padding:0 5px}
HTML
<div class="images">
<img alt="" src="../Images/img_1.png"/>
<img alt="" src="../Images/img_1.png"/>
</div>
This is a little less dynamic as you're locking in the image size in px instead of leaving it as a %. If you really need it to be dynamic, replace the px with % like this:
Code:
.images {clear:both; width:50%; margin:0 auto}
.images img {float:left; width:45%; padding:0 2.5%}
You can set the amount of screen space the images take up by changing the % in the .images width...for example, width:50% => width:75%
Edit:
If the different values for width are confusing just remember that the width refers to the container’s width. In this case, the img width is 45% of the containing div. The total width of the images + padding equals 100% of the div width.
For 2 images:
2.5%+45%+2.5% + 2.5%+45%+2.5% = 100%
For 3 images:
1.66%+30%+1.66% + 1.66%+30%+1.66% + 1.66%+30%+1.66% = 100%
The width of the div is the % of ITS container (the body/document)