Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Dynamically Changing CSS Stylesheet with Variables


Is it possible to change CSS depending on some variable?
For example, if $something= 2.3 then, can I add it as a modifier to a CSS element so that all passages will appear a certain way?

Comments

  • You need to state which story format you're using as the answer can be different for each!

    Sugarcane: You can use one of Leon's scripts to add the <<addtag>> macro to your project, then use that macro to conditionally add passage tags to your story, and then use CSS based on those tags to style it.

    SugarCube: You can use the built-in DOM (Classes) Macros within your passages to conditionally add CSS classes to your story and then use CSS based on those classes to style it.
  • Thanks, I'm using Sugarcane.

    I tried using Leon's script. Any idea if it's deprecated on 1.4.2?
  • Look at the script's code it appears that the tag based macros only works if it is called from within a passage that has already been assigned a tag using the passage editor, why this is so I don't know.

    A simple fix is to manually add a dummy tag (eg. aaa) using the passage editor to all the passages you plan to use <<addtag>> in.

    You may also want to PM Leon and ask him why it appears to work that way.
Sign In or Register to comment.