Post Archive

› March 10, 2004

Mimic the iFrame with CSS

  • Reported by Tony

Nigel Goodfellow has a good, easy-to-read article on creating stylish overflows using CSS. So if you want to mimic an iframe, here is a place that will help you walk through it in an easy-to-read and helpful manner.

Comments

1. March 10, 2004 09:17 AM

Quote this comment

andrew Posted…

Wrap my content in four divs? That's way too sloppy. Overflow divs can be made to work just fine using good structure.

2. March 10, 2004 09:45 AM

Quote this comment

Tony Posted…

The point wasn't that it was sloppy. And maybe "good" wasn't the proper word to describe it. It was that it was a good _intro_ on how to create the iFrame effect using CSS

I also liked his example of styling the "iframes" demonstrated later. And as I'm feeling lazy, I didn't feel like redoing the example into something semantically correct. But you can feel free to do your own how-to article.

3. March 10, 2004 10:30 AM

Quote this comment

Mike Posted…

Ya, I agree, it's way too much. There's no need to punish yourself using that many DIVs

4. March 10, 2004 10:46 AM

Quote this comment

Mike Posted…

Just because it says you have to use four divs, it doesn't mean you actually have to.

It's a nice introduction to the world of iFrames and it gives you some code and examples to work off of. I'm sure you guys know that you're allowed to modify and/or tweak the code Nigel gives to fit whatever site you're working on ;)

5. March 10, 2004 12:04 PM

Quote this comment

Janos Posted…

Still, is there a way to load dynamic content in these 'simulated' iframes?

Because I believe that it's the purpose of most of the iframes out there. Just as it was with frames back in '97... :)

6. March 10, 2004 12:16 PM

Quote this comment

steven Posted…

I agree with Janos. Isn't the purpose of iframes to load in external data so that you don't have to duplicate the entire page for each data set? I mean, great job on getting it to work, I just would need some way to dynamically load in external data.

7. March 10, 2004 02:56 PM

Quote this comment

Nigel Goodfellow Posted…

Just have a php include in there, and it should work out fine for having dynamic data in the css iframe. I'll make a little addition on to the tutorial about that for you. As for the four divs, yea. It's sloppy, but it eliminates the need for the box model hack. Hope you guys find it useful :)

8. March 10, 2004 04:30 PM

Quote this comment

Aegir Hallmundur Posted…

The problem I've found with people using divs instead of iframes is that the scrolling doesn't work from the keyboard cursor keys. I dislike having to exert super-fine control on the mouse/wacom/trackpad to scroll a few lines through a big block of text. In fact, despite the fact I'm a graphic artist and am used to such fine control, I find it difficult while reading - clearly the method is inaccessible to many people. Maybe it's my browser...

9. March 10, 2004 05:44 PM

Quote this comment

Janos Posted…

Nigel. I think you didn't understand what I was referring to when I said dynamic content. But let me exemplify. Suppose you have a site with a menu. Like, say: News, Interviews, About and a Miniforum... And you have a 'simulated' iframe on the site in which you want to present all the content of these sections.

It wouldn't be a problem with small snippets of text because you could preload everything and then when clicking on a menu point set the corresponding text in the div with a JavaScript function. But the news section can have many archive pages and the miniforum surely has lots of topics with many messages and preloading all this would be a serious bandwidth overkill. And I don't like the ideea of reloading the page (in it's whole) just because I want to change the content of the 'simulated' iframe.

So basically I'm looking for a solution to dynamically load the data in that iframe. If there is one, that is... Thanks for any upcoming ideeas.

10. March 10, 2004 06:59 PM

Quote this comment

Spider Posted…

the IE 5.2 on MACs adds a horisontal scrollbar, however there is a fix to this here: http://www.sam-i-am.com/work/sandbox/css/overflow-auto-fix.html (not tested it myself

11. May 20, 2005 09:25 PM

Quote this comment

Gordon Eckler Posted…

I have a similar problem. im working on a page for a photographer that i want to validate and use scrolling divs and not have to reload, it will have a seperate flash navigation system. does anyone have anything that will work?

12. May 22, 2005 03:08 PM

Quote this comment

Janos Posted…

Try toying around with XMLHttpRequest. It did it for me.