View Full Version : Style sheet variables?
Trinithis
06-09-2007, 12:58 AM
Is there a stylesheet language (CSS or not) that implements variables?
Something like this perhaps?
var i=0;
.class1 {
position: absolute;
left: ((i++)*10)px;
}
Where each class1 is 10px away from the previous one.
thetestingsite
06-09-2007, 01:04 AM
You could probably utilize javascript in some way to accomplish this. Also, you could use PHP to create a "dynamic" stylesheet if you really needed to. As for just using CSS, not sure if it is possible (but pretty sure it isn't).
Anyways, hope this helps.
There are two. One is an actual language, JSSS, which uses Javascript to implement stylesheets. Unfortunately, this existed only in older versions of Netscape, since it never really caught on. The other is IE's expression syntax, which allows one to use JScript to return the value of a property:
.class1 {
position: absolute;
left: expression( i++ * 10 + "px" );
}Unfortunately, neither are universal. CSS3 has some extensions to accomplish a bit more flexibility in stylesheets, but it's still a little confined.
Trinithis
06-09-2007, 01:29 AM
Well, thanks anyway. Guess I would have to resort to pure JS to do the trick with onloads or something.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.