Firdaus Adib
Firdaus Adib

Reputation: 11

LESS css variable not working

I am new to LESS and I'm using less.js as to my development environment. The problem is, when I declare a variable, it doest not working like nothing happen.

@bground: #c0c9c8;
body{
    background-color: @bground;
}

As you can see, the @bground does not pass it value. If I put direct value it will apear which is proof the .less is set up correctly. I'm using latest version of Chrome and running locally on Mac. Everything is working except variable. Without variables in work, I cannot use the LESS feature.

Upvotes: 1

Views: 3797

Answers (2)

Jijo thomas
Jijo thomas

Reputation: 1

Please make sure you loaded less js file in your page to accommodate less file.

use

<script src="//cdn.jsdelivr.net/npm/less" ></script>

for that.

Also while loading your less file use following syntax

<link rel="stylesheet/less" type="text/css" href="dist/css/<your less file>.less" />

make sure you use rel and type attributes on the tag, as mentioned.

Upvotes: 0

Evandro Silva
Evandro Silva

Reputation: 1402

If you`re using apache, create an .htaccess file in your root folder, if you already have one, just add this line:

AddType text/css .less

This will tell apache to send the right content-type header for the .less file

Upvotes: 2

Related Questions