View Full Version : How to center iframe content

Miss Coucou
07-03-2011, 01:20 PM
I am building an image gallery for my new website, using tables and iframe.
I am satisfied with the result for horizontal images, but I would like to center the vertical images, which now appear to the left (see attached file) :(.

Here's the HTML code I used for the iframe:

<iframe name="frmPhotos" src="images/TestiFrame/wolf.jpg" frameborder="no" "" scrolling="no" width="100%"></iframe><br />

I tried adding the following code to the iframe line without success:

If you know the solution, thanks in advance for sharing! :)

N.B. The images used here are not mine. They are used for test purposes only.

07-03-2011, 07:11 PM
You need to use margin:auto; to center non-textual elements.

I'm guessing your images are different sizes and there is a large gap on the first image so display might look strange. Since you are using javascript, it may be wise to seek out a lighbox gallery (http://www.lokeshdhakar.com/projects/lightbox2/) where all images are auto resized and have the same border.
Otherwise, try to make your photos the same size if possible.

07-04-2011, 12:57 PM

margin:0 auto;to center align black elements

Cheers :)