Jump to content

Dynamic CSS


diogo
 Share

Recommended Posts

What would be the best way of having dynamic CSS in all pages without making it heavy to process?

  • external style.php with a content-type header instead of style.css
  • internal stylesheet on header.inc, or on a dedicated include
  • other :)
Link to comment
Share on other sites

I think it depends how dynamic it will be. If you need a lot of .css then I would just make module which reads and writes css files. If you need to set few css rules like change bg image or stuff like that, then I would use inline css.

Link to comment
Share on other sites

In this case it's for a simple construction page. There will be three circles with some info and i want them to be in different positions every time the page loads.I only need dynamic margin-top and margin-left for each circle. For this one It's only one page, so I think I will do it as Apeisa suggested, but I was also wondering how to do it on a bigger website, even if it's only to have variables on css without using something like Sass.

Link to comment
Share on other sites

@Diogo:


  •  
  • in cases like this, it's  safe to go with inline styles - they work everywhere and properly documented, they're also easy to maintain, disregard haters - for simple randomization like this it's okay
     
  • if you want to do this on bigger scale, I would rather generate 5-10 CSS files (possibly with LESS, SASS, or PHP), and I would randomize which i include (rather than the properties themselves).This, way, you have both randomized CSS and less computing involved/caching available.
Link to comment
Share on other sites

I agree with Adam about using inline styles. There is a place where inline styles are appropriate, and this seems like a good example of one. Also, jQuery/Javascript is another thing to consider.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...