Connecting Tech Pros Worldwide Forums | Help | Site Map

Variables?

Oliver Block
Guest
 
Posts: n/a
#1: May 8 '06
Hi,

does anybody know if it's possible to assign variables within css files?

Best Regards,

Oliver


Beauregard T. Shagnasty
Guest
 
Posts: n/a
#2: May 8 '06

re: Variables?


Oliver Block wrote:
[color=blue]
> does anybody know if it's possible to assign variables within css
> files?[/color]

It is not possible.

--
-bts
-Warning: I brake for lawn deer
David Dorward
Guest
 
Posts: n/a
#3: May 8 '06

re: Variables?


Oliver Block wrote:[color=blue]
> does anybody know if it's possible to assign variables within css files?[/color]

http://dorward.me.uk/www/css/inheritance/ might be of use.

Evertjan.
Guest
 
Posts: n/a
#4: May 8 '06

re: Variables?


Beauregard T. Shagnasty wrote on 08 mei 2006 in
comp.infosystems.www.authoring.stylesheets:
[color=blue]
> Oliver Block wrote:
>[color=green]
>> does anybody know if it's possible to assign variables within css
>> files?[/color]
>
> It is not possible.
>[/color]

except serverside.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Beauregard T. Shagnasty
Guest
 
Posts: n/a
#5: May 8 '06

re: Variables?


Evertjan. wrote:
[color=blue]
> Beauregard T. Shagnasty wrote:
>[color=green]
>> Oliver Block wrote:
>>[color=darkred]
>>> does anybody know if it's possible to assign variables within css
>>> files?[/color]
>>
>> It is not possible.[/color]
>
> except serverside.[/color]

which would be writing a new/different CSS with each page-serve. <g>

--
-bts
-Warning: I brake for lawn deer
Evertjan.
Guest
 
Posts: n/a
#6: May 8 '06

re: Variables?


Beauregard T. Shagnasty wrote on 08 mei 2006 in
comp.infosystems.www.authoring.stylesheets:
[color=blue]
> Evertjan. wrote:
>[color=green]
>> Beauregard T. Shagnasty wrote:
>>[color=darkred]
>>> Oliver Block wrote:
>>>
>>>> does anybody know if it's possible to assign variables within css
>>>> files?
>>>
>>> It is not possible.[/color]
>>
>> except serverside.[/color]
>
> which would be writing a new/different CSS with each page-serve. <g>
>[/color]

css files are read and "execute" once anyway.
My suggestion means the css-fiel cashing has to be switched off,
so is not very practical.

in-file css however can easily be modified by serverside scripting:

<style>
body {font-size:<%=request.cookies("fontSz") %>pt;}
....

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
phil-news-nospam@ipal.net
Guest
 
Posts: n/a
#7: May 8 '06

re: Variables?


On Mon, 08 May 2006 16:51:33 GMT Beauregard T. Shagnasty <a.nony.mous@example.invalid> wrote:
| Evertjan. wrote:
|
|> Beauregard T. Shagnasty wrote:
|>
|>> Oliver Block wrote:
|>>
|>>> does anybody know if it's possible to assign variables within css
|>>> files?
|>>
|>> It is not possible.
|>
|> except serverside.
|
| which would be writing a new/different CSS with each page-serve. <g>

Generate it with PHP. PHP has variables.

--
-----------------------------------------------------------------------------
| Phil Howard KA9WGN | http://linuxhomepage.com/ http://ham.org/ |
| (first name) at ipal.net | http://phil.ipal.org/ http://ka9wgn.ham.org/ |
-----------------------------------------------------------------------------
David Dorward
Guest
 
Posts: n/a
#8: May 8 '06

re: Variables?


Beauregard T. Shagnasty wrote:[color=blue][color=green]
>> except serverside.[/color][/color]
[color=blue]
> which would be writing a new/different CSS with each page-serve. <g>[/color]

Only if you fail to send suitable cache control headers.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
phil-news-nospam@ipal.net
Guest
 
Posts: n/a
#9: May 8 '06

re: Variables?


On Mon, 08 May 2006 17:54:17 +0200 Oliver Block <news200605@block-online.eu> wrote:

| does anybody know if it's possible to assign variables within css files?

Do you want variables that are evaluated once?

CSS appears to be a language that defines the construction of a lookup table
which is (frequently) accessed for property information. If CSS were to
have an ability to assign values to variables and substitute them, it would
likely do so once as the code is parsed and evaluated, and the constants
placed in that lookup table structure.

Do you want variables that are evaluated at every lookup access?

Something would have to change those variables between lookup accesses for
that to have any useful effect. Would this be done in Javascript? What
about a DOM structure for the stylesheet?

Could special relationships be sufficient?

Maybe a value for one property could be based on some aspect of an object
already rendered, or to be rendered, such as specifying the width of one
object to be the same as that of another object, or the width to be twice
its height (say, to set a fixed aspect ratio).

--
-----------------------------------------------------------------------------
| Phil Howard KA9WGN | http://linuxhomepage.com/ http://ham.org/ |
| (first name) at ipal.net | http://phil.ipal.org/ http://ka9wgn.ham.org/ |
-----------------------------------------------------------------------------
phil-news-nospam@ipal.net
Guest
 
Posts: n/a
#10: May 8 '06

re: Variables?


On Mon, 08 May 2006 20:41:24 +0100 David Dorward <dorward@yahoo.com> wrote:
| Beauregard T. Shagnasty wrote:
|>> except serverside.
|
|> which would be writing a new/different CSS with each page-serve. <g>
|
| Only if you fail to send suitable cache control headers.

I think he means that the content would be different, and that a new CSS
file would have to be sent each time. If variable substitution is done
server-side, you'd have to disable caching, and then you'd have a new CSS
delivered each time, whether same or different. The idea I think he is
wanting to do is have some values in the CSS file be variables that can
be substituted at some point (based one something doing that, I know not
what) so that only one CSS file serves all purposes.

--
-----------------------------------------------------------------------------
| Phil Howard KA9WGN | http://linuxhomepage.com/ http://ham.org/ |
| (first name) at ipal.net | http://phil.ipal.org/ http://ka9wgn.ham.org/ |
-----------------------------------------------------------------------------
Beauregard T. Shagnasty
Guest
 
Posts: n/a
#11: May 8 '06

re: Variables?


phil-news-nospam@ipal.net wrote:
[color=blue]
> On Mon, 08 May 2006 20:41:24 +0100 David Dorward <dorward@yahoo.com> wrote:
>| Beauregard T. Shagnasty wrote:[/color]
[Evertjan wrote:][color=blue]
>|>> except serverside.
>|
>|> which would be writing a new/different CSS with each page-serve. <g>
>|
>| Only if you fail to send suitable cache control headers.[/color]

Only if the same named external css file is rewritten.
[color=blue]
> I think he [the OP] means that the content would be different, and
> that a new CSS file would have to be sent each time. If variable
> substitution is done server-side, you'd have to disable caching, and
> then you'd have a new CSS delivered each time, whether same or
> different. The idea I think he is wanting to do is have some values
> in the CSS file be variables that can be substituted at some point
> (based one something doing that, I know not what) so that only one
> CSS file serves all purposes.[/color]

I think you're right, phil. The OP didn't indicate that he knows about
(or thought about) writing CSS on-the-fly, so to speak.

It is trivial to write code to add or change <style></style> blocks in
the head of the pages.

--
-bts
-Warning: I brake for lawn deer
phil-news-nospam@ipal.net
Guest
 
Posts: n/a
#12: May 9 '06

re: Variables?


On Mon, 08 May 2006 20:58:37 GMT Beauregard T. Shagnasty <a.nony.mous@example.invalid> wrote:
| phil-news-nospam@ipal.net wrote:
|
|> On Mon, 08 May 2006 20:41:24 +0100 David Dorward <dorward@yahoo.com> wrote:
|>| Beauregard T. Shagnasty wrote:
| [Evertjan wrote:]
|>|>> except serverside.
|>|
|>|> which would be writing a new/different CSS with each page-serve. <g>
|>|
|>| Only if you fail to send suitable cache control headers.
|
| Only if the same named external css file is rewritten.

If it is really a dynamically generated object at the server, such as
a CGI program/script, or PHP, then that would be the effect of being
rewritten.


|> I think he [the OP] means that the content would be different, and
|> that a new CSS file would have to be sent each time. If variable
|> substitution is done server-side, you'd have to disable caching, and
|> then you'd have a new CSS delivered each time, whether same or
|> different. The idea I think he is wanting to do is have some values
|> in the CSS file be variables that can be substituted at some point
|> (based one something doing that, I know not what) so that only one
|> CSS file serves all purposes.
|
| I think you're right, phil. The OP didn't indicate that he knows about
| (or thought about) writing CSS on-the-fly, so to speak.
|
| It is trivial to write code to add or change <style></style> blocks in
| the head of the pages.

Perhaps what he had in mind was a big CSS file that had several variable
references within, and an @import for another CSS file that would have
some kind of settings for those variables. The big file can be cached
because it is static and never changes, while the other file might be
small and perhaps dynamically generated. Or maybe he will set those
variables in the HTML, such as within <style></style> if CSS did have a
way to set and use variables. It's an interesting concept. I'm not
sure how generally (as in for everyone) useful it would be.

I've found that some of what would otherwise be complex things can in fact
be done fairly simple by just referencing multiple classes from HTML elements
and letting the effects of those classes mix appropriately. I don't know
what the OP ultimately wants to accomplish, so I don't know if this would be
at least some way around his issue, or not.

As far as I know, there is no need for the file extension to be ".css" for
a file to be used as style. It just needs the correct MIME type and be
referenced in the appropriate context. If the extension is ".php" then
he could generate it with PHP easily enough by having the server treat it
as such.

--
-----------------------------------------------------------------------------
| Phil Howard KA9WGN | http://linuxhomepage.com/ http://ham.org/ |
| (first name) at ipal.net | http://phil.ipal.org/ http://ka9wgn.ham.org/ |
-----------------------------------------------------------------------------
RC
Guest
 
Posts: n/a
#13: May 10 '06

re: Variables?


Oliver Block wrote:
[color=blue]
> does anybody know if it's possible to assign variables within css files?[/color]


Hahaha.....!! I know what you want, but the answer is impossible.

Sometimes, you can use JavaScript to change the value(s) of CSS.
Closed Thread