Jump to content

Recommended Posts

Posted

I have a website where the client can set different colors via input fields on a page in the backend. I want to make use of those colors as CSS vars to use them in my stylesheets. I am doing it this way:

<style>
  :root {
    --primary-color: <?=$globalSettings->bg_colorcode?>;
    --secondary-color: <?=$globalSettings->font_colorcode?>;
    --tertiary-color: <?=$globalSettings->titlefont_colorcode?>;
  }
</style>

Then I can simply "grab" those variables in my stylesheets:

header {
  background: var(--primary-color);
}

I am using UIKit and LESS and this is working for me.

  • Like 2

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
  • Recently Browsing   0 members

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