1

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.

4
  • 3
    Just to make sure, do you first include the CSS <link rel="stylesheet/less" type="text/css" href="styles.less"> and then the javascript <script src="less.js" type="text/javascript"></script>on the page in question? Commented Sep 4, 2012 at 19:13
  • @HenrikAmmer Yes I did. The stylesheet first and the Less.js after that. Commented Sep 4, 2012 at 19:35
  • Do you use the console in Chrome and/or Firebug in Firefox? If so, do you see any errors in the console regarding if something went wrong? Commented Sep 4, 2012 at 19:38
  • There are an error : Resource interpreted as Stylesheet but transferred with MIME type text/plain: "file://localhost/Users/Firdaus/Documents/WebProject/HackerHiresV2/less/main.less". Commented Sep 4, 2012 at 19:49

2 Answers 2

2

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

Sign up to request clarification or add additional context in comments.

2 Comments

This is the error I found : <img src="i.invoture.com/thumbs/screenshot.png">
It is solved. Before this, I'm using direct file:// but there are no error in my console. So what I did is I tested on server by upload it in live server and it works like a charm. So the LESS.js need to work with XMLHttpRequest which is direct file:// dont have. Now I'm using MAMP and I marked this as solved. Thank you gentleman!
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.