Charas-Project

Off-Topic => Really Old Stuff => Archive => HTML & DHTML => Topic started by: Zerlina on July 18, 2005, 06:09:13 PM

Title: Iframe positioning help
Post by: Zerlina on July 18, 2005, 06:09:13 PM
Hey, all you html experts out there.

I'm working on my game website, and I'm having trouble.


http://www.freewebs.com/palisgame/

The problem is that I'm trying to put an iframe over an image. In 800x600 resolution, the iframe is in the right place, but in 1024x768 + it's always too far to the left. How would I fix this? I thought of putting the image on a layer, too, but then it would always be off-centre.

Any help appreciated.


Title:
Post by: Sqoad on July 18, 2005, 11:55:16 PM
I used to work a little with that... But I have forgotten most of it...
Well you COULD look for a html guide or something... But... You could try asking someone who has his/her own website... Or wait until someone more intelligent wants to help :|

EDIT: Pretty good so far though XD
Title:
Post by: AsakuraHao2004 on July 19, 2005, 01:19:39 AM
The obvious thing, have you closed your iframe tag? Something like that happened to me, almost exactly like what you're describing. Turns out I forgot to close the iframe tag.

Changing resolution size changes picture sizes, no? That way, if you have the ifame set to a specific width and height, it wont change when the image does (or, it will, but it causes problems). (course, Im hazy with that, not too sure... I dont change resolustions much)

Also, when putting an iframe over an image, it might be best to use tables. Set the image as a TD background. Thats what I use for content boxes.

Of course, frames are always unpredictable, and have low compadability. It might be best to put a note in between iframe tags "Your browser does not recognize iframe. (get firefox ^_~)".


Hope that helps.
Title:
Post by: Osmose on July 19, 2005, 02:08:10 AM
Actually, his problem is simple.

Change this:
 
Quote


To this:
 
Quote


If it's still a bit offkilter after that, just tweak the iFrame X and Y to fit again and it will work.

Because the image is centered it will change dynamically with a resolution change to stay in the center of the user's screen. The iFrame, on the other hand, is in a static position, therefore not moving along with the centered picture.\


 
Quote
Changing resolution size changes picture sizes, no?


No it does not. Changing resolutions changes the size of your screen. An image that is 100x100 at a higher resolution will still be 100x100 at a lower resolution. The difference is that your screen will display all pixels bigger. Think of it as drawing a box around part of your current res and expanding that - the only thing changing is your view. Well, that and things like aligning that are dynamic to the resolution.

 
Quote

Also, when putting an iframe over an image, it might be best to use tables.


Again, no. iFrames are made specifically so they can be seperated from the rest of the screen. Fact is, if he had made the image the background of a table, a little fancy cell work could've removed the need for an iFrame at all, plus made the page easier to update and cleaner from a coding point of view. Of course, this would've required him to split the background image into a few images, but that's the tradeoff for the benefits - more work, more rewards.

Another side benefit of tables: If you have one of those fancy gradient bars, and you want to reduce filesize as well as be able to put text, like a title, on top of it, you can set the bar to being one pixel wide and as tall as you want. Putting it as the background of a table would stretch it to make it look the same as a wide version, with an infinately smaller filesize.
Title:
Post by: AsakuraHao2004 on July 19, 2005, 02:21:58 AM
Meh... I'm backed into a corner. I used sliced up photoshop images because I suck at mapping out a site manually, then throw an iframe where the content box is, switching the image to the background.

Whatever works for you I guess.
Title:
Post by: Zerlina on July 19, 2005, 02:34:39 AM
Is there a way to have it centred while still keeping the iframe in the content spot?
Title:
Post by: Osmose on July 19, 2005, 03:57:16 AM
From what I know, I don't believe so. The only way would be to get the user's resolution(there's a simple way to get it through Javascript, I believe) and edit the X and Ys accordingly, but even that wouldn't be compatible with everything.

The only way I can think of is putting the entire page within another iFrame and then centering that, but I'm not sure if iFrames can be nested, or if it will work right if they can. It won't look that bad just because it's not centered.

Or you could use tables only, like I mentioned before.
Title:
Post by: Zerlina on July 19, 2005, 05:28:45 PM
Ok I fixed it. I just put the content on a popup so that it wouldn't matter if it was aligned to the left or centre.

Thanks for the help! :)