Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Inmedia 124 posts 176 karma points
    May 01, 2012 @ 13:00
    Inmedia
    0

    Macro in Stylesheets... possible?

    Does anyone know if it's possible to somehow add proberty values inside stylesheets...

    Say for instance you want the end user to be able to set a color code for all links?

    How would you do that?

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 7x admin c-trib
    May 01, 2012 @ 13:09
    Chriztian Steinmeier
    0

    Hi Inmedia,

    You can do that by creating a property on the "Home" document type (or a "Settings" type, whichever fits the situation) - either as a simple Textstring accepting a valid CSS color (e.g., "#fff", "lime" or "rgba(0, 255, 0, 0.4)" etc.) - OR - you could use the "Approved Color" data-type and add some sensible prevalues...

    Then in the <head> section of your Master Template create a simple <style> element where you output the value as a valid CSS rule. Just remember to add it after any Stylesheets.

    You can use a complete macro or some simple Razor code to do the outputting...

    /Chriztian 

  • Inmedia 124 posts 176 karma points
    May 01, 2012 @ 13:26
    Inmedia
    0

    But then it will be internal/inline CSS... I always like to keep my HTML files free of any CSS, keeping it in the external stylesheets.

    But it is not possible to add the values directly into the extarnal stylesheets somehow?

  • Inmedia 124 posts 176 karma points
    May 01, 2012 @ 13:26
    Inmedia
    0

    But then it will be internal/inline CSS... I always like to keep my HTML files free of any CSS, keeping it in the external stylesheets.

    But it is not possible to add the values directly into the extarnal stylesheets somehow?

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 7x admin c-trib
    May 01, 2012 @ 13:54
    Chriztian Steinmeier
    1

    Hi Inmedia,

    I agree about separating stuff, but really - you *could* put the macro on a separate template and use that template as the result of a .css request (remember to set the correct HTTP header), but then you've created an extra HTTP request, which has way more impact on page load time, than a single line of styles.

    If you're not planning on making a lot of the CSS "skinnable" in this way, I'd go with the very simple solution...

    /Chriztian

  • Inmedia 124 posts 176 karma points
    May 01, 2012 @ 14:01
    Inmedia
    0

    Yes, I guess you are right about that.

    And I only need the end user to be able to change some standard stuff, like link colors and so... So I will go with the simple solution :)

    Thank you for the help ;)

Please Sign in or register to post replies

Write your reply to:

Draft