Forum Moderators: not2easy
I have various child pages that are included by their parent pages using the 'iframe' element. These child pages have styles defined like so:
<style type="text/css" media="screen">
@import "styles.css";
body {margin: 1%;}
/*other style definitions that tweak styles defined in the external style sheet*/
</style>
This seems to cause problems for Opera 7 (not IE or Firefox). When a child page is first loaded, Opera does not load the styles that follow the '@import' command (it only uses the style definitions contained in the imported style sheet. However, when the page is refreshed, these styles are loaded correctly.
As a workaround, I have had to remove the extra styles from the 'style' element, and make them in-line styles (an undesirable compromise!)
Does anyone know why Opera is behaving in this way? I would prefer not to have to resort to using in-line styles.
Thank you!
I am using Opera version 7.23.
It doesn't appear to be a cache problem. I've just created a dummy parent page, child page, and stylesheet, loaded it for the first time, and the same problem happens in Opera.
I have put the dummy pages online at <Sorry, no personal URLs. See TOS [webmasterworld.com]>
In Opera, the child page inside the iframe should first have a blue background, then when you reload the page, the background colour should change to white and the margin should change too.
I have looked at [centricle.com...] but it doesn't seem to indicate any problem with Opera 7 and what I am doing.
Thank you for your help!
[edited by: tedster at 5:38 pm (utc) on April 17, 2004]
I tested your page online with 7.23, problem in the iframe, it isn't white unless when reloaded.
I tested locally, replacing teststyle.css with one of my stylesheets,
no problem, everything works: background-color, margin.
tested red, margin 100px...
no need to reload...
The problem does just seem to be with the '@import command'. When I linked the external stylesheet using a <link> tag, the page loaded correctly in Opera the first time.
To summarise:
The external stylesheet contained:
body {background-color: #7BC2FD;
margin:20px;}
My first attempt at importing the stylesheet imported the stylesheet but subsequent style defintions were ignored when the page was first loaded:
<style type="text/css" media="screen">
@import "teststyle.css";
body {background-color: #FFFFFF;
margin:1px;}
</style>
When I linked the external stylesheet (instead of importing it), the styles on the page loaded correctly in Opera:
<link href="teststyle.css" rel="stylesheet" type="text/css">
<style type="text/css" media="screen">
body {background-color: #FFFFFF;
margin:1px;}
</style>
It's not essential for me to import the stylesheet, so I'm happy just to link it. Still a bit perplexing as to why Opera did not load the styles correctly however.