Connecting Tech Pros Worldwide Forums | Help | Site Map

Access style by name of external file?

Markus Ernst
Guest
 
Posts: n/a
#1: Jul 20 '05
Hi

I build a small content management system. I use different external
stylesheets for the admin section and the frontend, called admin.css and
frontend.css.

Now I would like to preview some frontend stuff in the admin section. Is
there a syntax for accessing a style from a different style sheet? For
example:

admin.css says:
h1 {
color:red;
}
p {
font-family:sans-serif;
}

frontend.css says:
h1 {
color:blue;
}
p {
font-family:serif;
}

in a file admin.html I would like to do something like:

<head>
<link rel="stylesheet" href="admin.css" type="text/css">
<link rel="alternate stylesheet" href="frontend.css" type="text/css">
</head>
<body>
<h1>Red headline</h1>
<p>Some sans serif text here</p>

<div stylesheet="use alternate stylesheet, is that possible?">
<h1>Blue headline</h1>
<p>Some serif text here</p>
</div>

</body>

I am grateful for a hint on that.

--
Markus



Michael Rozdoba
Guest
 
Posts: n/a
#2: Jul 20 '05

re: Access style by name of external file?


Markus Ernst wrote:
[color=blue]
> Hi
>
> I build a small content management system. I use different external
> stylesheets for the admin section and the frontend, called admin.css and
> frontend.css.
>
> Now I would like to preview some frontend stuff in the admin section. Is
> there a syntax for accessing a style from a different style sheet?[/color]

Not that I know of, however I'm new to CSS.
[color=blue]
> For
> example:
>
> admin.css says:
> h1 {
> color:red;
> }
> p {
> font-family:sans-serif;
> }
>
> frontend.css says:
> h1 {
> color:blue;
> }
> p {
> font-family:serif;
> }
>
> in a file admin.html I would like to do something like:
>
> <head>
> <link rel="stylesheet" href="admin.css" type="text/css">
> <link rel="alternate stylesheet" href="frontend.css" type="text/css">
> </head>
> <body>
> <h1>Red headline</h1>
> <p>Some sans serif text here</p>
>
> <div stylesheet="use alternate stylesheet, is that possible?">
> <h1>Blue headline</h1>
> <p>Some serif text here</p>
> </div>
>
> </body>
>
> I am grateful for a hint on that.[/color]

If you can't find a clean CSS solution, & this is just for internal
previewing, how about duplicating your stlyesheets & then indenting each
line in each such duplicate with something like
..sheet<name>
for some suitable <name>

You can then apply any of those styles by including within an object to
whom you give class sheet<name> & linking to the indented sheets.

If you need to make many changes to the sheets & preview each time, you
could automate generation of the indented sheets with a little bit of
perl or other suitable language.

Maybe you'll get a simpler solution.

--
Michael
m r o z a t u k g a t e w a y d o t n e t
Markus Ernst
Guest
 
Posts: n/a
#3: Jul 20 '05

re: Access style by name of external file?


"Michael Rozdoba" <mroz@nowhere.invalid> schrieb im Newsbeitrag
news:3fff5251$0$203$fa0fcedb@lovejoy.zen.co.uk...[color=blue]
> Markus Ernst wrote:
>[color=green]
> > Hi
> >
> > I build a small content management system. I use different external
> > stylesheets for the admin section and the frontend, called admin.css and
> > frontend.css.
> >
> > Now I would like to preview some frontend stuff in the admin section. Is
> > there a syntax for accessing a style from a different style sheet?[/color]
>
> Not that I know of, however I'm new to CSS.
>[color=green]
> > For
> > example:
> >
> > admin.css says:
> > h1 {
> > color:red;
> > }
> > p {
> > font-family:sans-serif;
> > }
> >
> > frontend.css says:
> > h1 {
> > color:blue;
> > }
> > p {
> > font-family:serif;
> > }
> >
> > in a file admin.html I would like to do something like:
> >
> > <head>
> > <link rel="stylesheet" href="admin.css" type="text/css">
> > <link rel="alternate stylesheet" href="frontend.css" type="text/css">
> > </head>
> > <body>
> > <h1>Red headline</h1>
> > <p>Some sans serif text here</p>
> >
> > <div stylesheet="use alternate stylesheet, is that possible?">
> > <h1>Blue headline</h1>
> > <p>Some serif text here</p>
> > </div>
> >
> > </body>
> >
> > I am grateful for a hint on that.[/color]
>
> If you can't find a clean CSS solution, & this is just for internal
> previewing, how about duplicating your stlyesheets & then indenting each
> line in each such duplicate with something like
> .sheet<name>
> for some suitable <name>
>
> You can then apply any of those styles by including within an object to
> whom you give class sheet<name> & linking to the indented sheets.
>
> If you need to make many changes to the sheets & preview each time, you
> could automate generation of the indented sheets with a little bit of
> perl or other suitable language.
>
> Maybe you'll get a simpler solution.
>
> --
> Michael
> m r o z a t u k g a t e w a y d o t n e t[/color]

Thank you for your idea Michael. What I actually did now was a variant of
your solution: I made a separate stylesheet file for the content section and
put all the contents into a div with the id "content". And the styles are
defined as

#content h1 { ... }
#content p { ... }

and so on. So I can import that same stylesheet file into the admin preview
file without affecting the admin-specific definitions of h1 and p and so on.

--
Markus


Closed Thread