Click to See Complete Forum and Search --> : Centring iframe


IxxI
02-10-2003, 10:53 AM
I have an iframe so that viewers of a web page can see it whether they have large resolutions or small resolutions. I was wondering how I could make it so that it is automatically centred no matter what their resolution is.
Thanks,
IxxI

webGirl20032003
02-10-2003, 11:22 AM
Would this work?

Add this as shown below. width="100%"


<iframe name="I1" src="http://www.webdeveloper.com" width="100%">
Your browser does not support inline frames or is currently configured not to display inline frames.</iframe>

khalidali63
02-10-2003, 12:52 PM
<div align="center">
<iframe ></iframe>

</div>

this should center the iframe right in the middle of the page.

cheers

Khalid

IxxI
02-11-2003, 07:56 AM
Thanks Khalid, but thats what I've got at the moment and it only centres it horizontally not vertically, so its stuck at the top but centred. Sorry - I forgot to say when I posted. I meant to say is there a way to centre it vertically on the page. And if the div ciommand should can you think of a reason why it doesn't?
IxxI

pyro
02-11-2003, 09:32 AM
This will center your iFrame in Netscape... In IE, it will not work as well. (That's odd, a JavaScript that works better in NN...hmm...:)) In IE, what it will do is position itself in the middle if the browser is full screen, with all the toolbars. In NN, it will position itself in the center no matter what. (Unless JavaScript is disabled, of course!)

IxxI
02-11-2003, 10:13 AM
Cheers Pyro, it works fine in IE except if I change my resolution to 800x600 (my iframe size is 760x540) when it cuts of the top 20 pix or so (when I say cuts off I don't mean that you have to scroll to see them but that you CAN'T scroll up to see them).
Any idea why this might be happening,
Thanks again,
IxxI

pyro
02-11-2003, 11:20 AM
Ok, I've added a screen resolution detector that detects if the screen resolution is 800 x 600 or less and adjusts accordingly. I also added a <noscript> tag so users with javascript turned off will at least get the iframe content, it just won't be centered.

IxxI
02-12-2003, 06:42 AM
Cheers, works fine now.
IxxI