css variables with values coming from the database

1

I'm developing a website where I saw myself needing to bring the style (colors) of the elements of the database. This would be a piece of cake if it were a page because (for relaxation) I could write the css in head of the document and bring the variables with the values of the database. But the website is great and I need to use a css separate file and link the pages that use those styles, because as a matter of performance I do not like to think about writing the same stylesheet in head of each page .

I have researched on the subject and I have seen names of preprocessors like: PostCSS , SASS , LESS , etc.

Since I never saw anything on the subject then I wanted to know if you have any way to make the variables come from the bank (the language I use is classic asp), or if it is only possible with such preprocessors, and if , just working with them wanted to tell me which would be good to use and if they allow you to bring the values from the database.

If you have not understood my question or think that it is not complete, just ask that I am waiting to clear my doubts. Thanks in advance.

    
asked by anonymous 19.07.2017 / 15:55

1 answer

2

Just import the css as php

<link rel="stylesheet" href="estilo.php" type="text/css" />

In php add

<?php
header("Content-type: text/css");

//configura as variáveis

?>

//Saida Css

body {
background: <?php echo $cor_fundo; ?>;
}
    
19.07.2017 / 16:08