View Full Version : Styling content within Iframe

10-01-2008, 01:58 AM
Is there any way for me to style content within an iframe by doing something to the iframe code or is the only way to do it is to style the content within and then load it in the iframe?

I am trying to center and change the height of an image being display within my iframe, but problem is I want to display around 100 no way I can create a page with the style for each and everyone of them....:mad:


10-01-2008, 12:38 PM
No, you can't control the styling of anything loaded within an iframe from outside of it. You might want to rethink how you're loading the images within the iframe.

A little php would make this fairly easy. If all that you're doing within the iframe is loading an image, you might try something like this:

$img = $_GET['img']
<img src="path/<?php echo $img; ?>" alt="image">

Then, you could just add CSS styling to that one page. You would call different images as such: image.php?img=filename.jpg

This is fairly basic. You might want to make a little more robust for real application. But, nonetheless, it does what you need without having to create 100 different pages.

12-06-2008, 08:17 PM
i tried the code you posted, and it works well. i am now wondering how to maintain scrollbar postition? i like the iframe because if you have a div on the left with nav, and say a content div in the middle, the scrollbar stays in the same place. the drawback is that the URL is the same for every image. i'd like people to be able to copy the URL ...but i'd also like the scrollbar not to reset after each image is retrieved. is there any way to do this?