Results 1 to 4 of 4

Thread: Style sheet variables?

  1. #1
    Join Date
    May 2007
    Location
    USA
    Posts
    373
    Thanks
    2
    Thanked 4 Times in 4 Posts

    Default Style sheet variables?

    Is there a stylesheet language (CSS or not) that implements variables?

    Something like this perhaps?
    Code:
    var i=0;
    .class1 {
    position: absolute;
    left: ((i++)*10)px;
    }
    Where each class1 is 10px away from the previous one.

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    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.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. #3
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    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:
    Code:
    .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.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  4. #4
    Join Date
    May 2007
    Location
    USA
    Posts
    373
    Thanks
    2
    Thanked 4 Times in 4 Posts

    Default

    Well, thanks anyway. Guess I would have to resort to pure JS to do the trick with onloads or something.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •