Previous Message
Next Message

Re: [css-d] css switcher and cache

Sent by Eric A. Meyer on 30 January 2002 14:02


At 19:15 -0500 1/29/02, Ryan Schroeder wrote:

>I've been playing with ALA's style sheet switcher at
>http://www.centralsq.com and have found that when switch CSS IE5.1/Mac will
>retain the previous css unless explicitly overwritten in the new style
>sheet.

    Based on Ryan's test page at http://www.centralsq.com/switch/, I 
think I've discovered that the error is actually in the authoring-- 
but it's a subtle, tricky error, and one I stumbled over myself 
several times when I set up a switcher.
    If you go to the 'switch' URL, you'll find near the top two links: 
"Default" and "Two".  Click on "Two" to get a nice palm tree.  The 
wheelbarrow graphic is supposed to go away, and it doesn't.  The 
reason why is sort of interesting, and nicely illustrates the whole 
"alternate" versus regular stylesheet idea.
    The "wheelbarrow" graphic is actually a background image.  It's 
called for in the file 'central.css':

#dotframe
{	background: #888;
	width: 650px;
	padding: 50px;
	background: url(header.gif);
	background-repeat: no-repeat;
	background-attachment: fixed;
}

'central.css' is linked in but its 'rel' is 'stylesheet', which means 
it will always apply to the page.  This is true no matter which 
alternate stylesheet you pick.  Therefore, getting rid of the graphic 
means you have to take steps.
    The most straightforward solution here would be to suppress the 
graphic using his alternate stylesheet.  For example:

#dotframe
{
	width: 650px;
	margin-top: 10px;
	margin-left: auto;
	margin-right: 10px;
	margin-bottom: 10px;
	border-color: #000;
	border-width: 1px 0px 1px 0px;
	border-style: solid;
	background-image: none;   /* needs to be added */
}

That would prevent any image from being filled into the background of 
the "dotframe," at least given Ryan's styles as currently constructed.
    So, given the way Paul Snowden's switcher (the one Ryan and I both 
use) operates, you get to choose which of the alternate stylesheets 
will be applied to the page.  But if you have a non-alternate 
stylesheet, it will always be applied to the page.  On meyerweb.com, 
I link to 'basic.css' as usual, and then define the various extra 
choices (monochrome, sunrise, lunar sky, etc.) as alternates (check 
the page source if you're curious).  When a user picks an alternate, 
they effectively add their choice to the basic styles.  When the user 
picks 'basic styles', they're turning off the additional stylesheet 
and returning to a page styled just by 'basic.css'.  In every case, 
'basic.css' is styling the page.
    This is how Mozilla/NS6.x handles alternate stylesheets as well, 
and as more browsers add support for alternate stylesheets the odds 
are they'll act in the same fashion.

--
Eric A. Meyer (http://www.meyerweb.com/eric/), List Chaperone
"CSS is much too interesting and elegant to be not taken seriously."
   -- Martina Kosloff
Previous Message
Next Message

Message thread: