Forum Moderators: coopster
Then the switch/case script imports the desired stylesheet.
What is wrong with this script (because it doesn't work)?
Okay I know it is the "@import/blue.css"; but I can't figure out what it should be. Is there a site that explains how to do it?
case "blue":
echo "@import/blue.css";
break;
echo "<style media=\"screen\" type=\"text/css\">
@import blue.css;
</style>";
The PROBLEM now is that when the blue (or any other color) stylesheet is selected only the portion that has content will will turn blue. Everything below the contentt will remain unchanged UNLESS the same color is selected again. If a color is selected twice, then the entire screen will turn the selected color. (Maybe I should mention that the CSS stylesheets have only the background attributed selected for the body.)
In other words if there is content halfway down the page the background will turn the selected halfway down the page, but if the same color is selected a second time the entire screen will be the selected color.
What needs to be done to get the entire screen to fill with the correct color the first time out?
How about posting the CSS for us? And maybe some sample html?
It sounds to me as if you're importing the stylesheet in the wrong place. It should be placed in the <head></head> element. When the stylesheet is selected, what happens? Is the page loaded again or is the <style> tag printed into the page?
After posting I realized that this is more of a CSS problem than PHP, but initially wasn't sure of it.
What I've come up with I realize isn't correct and for some reason it is the only way I can get it do what I need it to do.
case "blue":
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"blue.css\">
<style type=\"text/css\">
@ import url(blue.css);
</style>";
break;
I've tried moving the first line 'link rel' to the <head> tag and left the 'style' section inside the case. It loads the stylesheet up initially, but on subsequent calls it fails to reload.
Now I'm not so sure if it is a CSS problem or PHP or both because it does work with Javascript when the 'link rel in is the head section--just not PHP.