Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

less.css variables initialized from database

Tags:

c#

css

less

I am using dotnetless (http://www.dotlesscss.org/) for asp.net web forms applications, and it works great. I like using variables for colors, font-size etc. But so far as I can see variable values are static.

Is there any way using dotnetless to initialize these variables values from a database depending on userid?

Basically I want to convert this web application into a theme based website, so each user can select there own color, font, font-size etc.

Any direction will be greatly appreciated.

like image 720
daljit Avatar asked May 30 '13 15:05

daljit


People also ask

Can you use CSS variables in less?

You can import a . less file, and all the variables in it will be available.

How do you import less variables?

The best way to do this is to @import your LESS file with all your variables in it. Here's the syntax for the @import keyword: // For LESS file includes, @import "lib. less"; // or @import "lib"; // infers the .

What does VAR () do in CSS?

The var() function is used to insert the value of a CSS variable. CSS variables have access to the DOM, which means that you can create variables with local or global scope, change the variables with JavaScript, and change the variables based on media queries.


1 Answers

It is definitely possible, but unfortunately you can't query your database from LESS itself, so you basically need to write the LESS file for the user with the variable values needed, and then load it.

You can find an example from another answer here: https://stackoverflow.com/a/11628325/2330244

like image 195
Jesús Carrera Avatar answered Sep 19 '22 15:09

Jesús Carrera