less.js icon indicating copy to clipboard operation
less.js copied to clipboard

Unable to get a single LESS.js example to work.

Open lppdev opened this issue 14 years ago • 9 comments

I am testing both locally and on my server. My folder contains 2 files:

1- INDEX.HTML
which looks like this:
<!DOCTYPE HTML>
<html lang="en">
    <head>    <meta charset="UTF-8">    
        <title>Untitled Document</title>
        <link rel="stylesheet/less" type="text/css" href="style.less">
        <script src="http://lesscss.googlecode.com/files/less-1.0.18.min.js"></script>
    </head>
    <body>
        <a href="#" class="myLESS_CSS">Submit</a>
    </body>
</html>
2-STYLE.LESS
which looks like this:

@basic-color: #ff0000;

.myLESS_CSS{
background: @basic-color;
display: block;
width: 400px; height: 100px; margin: 50px auto; font-family: helvetica,arial; font-weight: bold; font-size: 100px; line-height: 100px; text-align: center;
text-decoration: none; text-shadow: 0px 2px 0px (@basic-color + #555); color: #333; }

Either locally or live the results look like this: http://www.leadminepond.com/tutorials/less/

When I enter "http://www.leadminepond.com/tutorials/less/style.less" in either IE9 or Chrome I get a 404 error saying the file does not exist, but it is in the folder. Any thoughts?

Thanks! John

lppdev avatar Jan 31 '12 14:01 lppdev

Off the top of my head: could be that the server doesn't want to serve .less files (try renaming it to style.less.css and see if that works) or that its permissions are strange. Though the local testing of this should have worked. Is it locally, as in a server on your computer (http://localhost/...) or directly (file:///...)?

souldreamer avatar Feb 01 '12 10:02 souldreamer

Hey SoulDreamer,

Thanks for the reply. My local testing has been http://localhost/html5_studies/less/ where less is the directory containing the two files mentioned above. Testing directly (file:///) yields the same results. Server is running Windows 2008, my local machine is running Windows 7.

I tried your suggestion of adding a '.css' extension but got the same results. Any other ideas?

Thanks again! John

lppdev avatar Feb 01 '12 13:02 lppdev

Change the html page to include style.less.css instead of style.less, because your webserver serves that (if you try to access .../style.less it doesn't work, but .../style.less.css is served just fine). Sounds like it actually doesn't serve .less files (in which case, look for a tutorial on how to change that and give it the text/css (not sure this is the best/recommended, but it works for me with lighttpd) mimetype.

souldreamer avatar Feb 02 '12 07:02 souldreamer

Hey SoulDreamer,

Thanks again for the reply. I have tried that, both locally and on the server but no luck in either IE9 or Chrome.

Thanks, John

lppdev avatar Feb 03 '12 14:02 lppdev

Hi Ippdev,

Not sure if you still looking for the solution, in case you are, then try adding a new mimetype in IIS.

extension = .less
mimetype = text/css

xionhunt avatar Feb 27 '12 01:02 xionhunt

Hi Ippdev - I have the same problem. Just started working with LESS, have test files which are quite happily showing up with styles in Safari and FF, just pointing browser at file:/// etc. IE9 and Chrome totally ignore the style. Installed IIS as I read (at http://stackoverflow.com/questions/3084892/less-js-not-working-in-chrome) that Chrome needed to understand LESS through a webserver. No difference. IE9 and Chrome are devoid of styles. Hope someone knows what might be happening here. ta folks

Greenie10 avatar Mar 02 '12 10:03 Greenie10

After another 26(!) minutes of research, I tried removing a previous attempt to get it to play with IE9 and Chrome, which was to add an absolute path to both the .less and the .js files in the html. I removed the absolute paths, and now both ie9 and Chrome show the styles properly, but only by browsing through localhost, not file:/// hth

Greenie10 avatar Mar 02 '12 11:03 Greenie10

Can anyone say what this bug is and what needs to be changed? I'm tempted to close it...

lukeapage avatar Jul 22 '12 15:07 lukeapage

Looks like server error not being able to see .less files, I guess there's use of putting it on the client here rather than compiling and just pushing the css to the server. I'd suggest closing, no comments or bumps in 5 monhts cc @Ippdev @agatronic

sturobson avatar Jul 23 '12 08:07 sturobson