Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. css variables

css variables

Scheduled Pinned Locked Moved Web Development
csshelpquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    benams
    wrote on last edited by
    #1

    I want to add a variable to a css class. Is it possile? I mean I want to do something like the following: #box[i] { padding: [i]px; } I understand this may not be the right syntax, but I hope you can help me achieve the concept setting my class' properties up to a variable value.

    G N A 3 Replies Last reply
    0
    • B benams

      I want to add a variable to a css class. Is it possile? I mean I want to do something like the following: #box[i] { padding: [i]px; } I understand this may not be the right syntax, but I hope you can help me achieve the concept setting my class' properties up to a variable value.

      G Offline
      G Offline
      Gregory Gadow
      wrote on last edited by
      #2

      This is something that a lot of people want, and it will likely be available in future releases of CSS. Right now, though, this is not possible. What you can probably do, though, is give your objects a class name -- say, flexiblePadding_x, then have a bit of Javascript that runs when the page is loaded searches for all elements having "flexiblePadding_" in their class, makes a note of x, removes the class and adds the appropriate style to the element. It will be a bit of work, but it should get you the results you want.

      1 Reply Last reply
      0
      • B benams

        I want to add a variable to a css class. Is it possile? I mean I want to do something like the following: #box[i] { padding: [i]px; } I understand this may not be the right syntax, but I hope you can help me achieve the concept setting my class' properties up to a variable value.

        N Offline
        N Offline
        Not Active
        wrote on last edited by
        #3

        This is one implementation CSS Variables[^]


        Failure is not an option; it's the default selection.

        1 Reply Last reply
        0
        • B benams

          I want to add a variable to a css class. Is it possile? I mean I want to do something like the following: #box[i] { padding: [i]px; } I understand this may not be the right syntax, but I hope you can help me achieve the concept setting my class' properties up to a variable value.

          A Offline
          A Offline
          Anurag Gandhi
          wrote on last edited by
          #4

          For such similar things you may use expressions in css also. Just google "Expressions in CSS" and you will get a lot of result.

          Anurag Gandhi.
          http://www.gandhisoft.com
          Life is a computer program and every one is the programmer of his own life.
          My latest article: Group GridView Data

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups