I have this html code :
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<link rel="stylesheet/less" type="text/css" href="1.less" />
<script type="text/javascript" src="less-1.3.0.min.js"></script>
<title></title>
</head>
<body>
<div id="t1">t1</div>
<div id="t2">t2</div>
</body>
</html>
and this is the 1.less :
.transition {
-ms-transition: all 0.3s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
-webkit-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
}
.shadow {
padding: 10px 10px 10px 10px;
margin: 10px 10px 10px 10px;
-moz-box-shadow: 0px 0px 10px #808080;
-o-box-shadow: 0px 0px 10px #808080;
-webkit-box-shadow: 0px 0px 10px #808080;
box-shadow: 0px 0px 10px #808080;
}
.shadow:hover {
-moz-box-shadow: 0px 0px 10px #a5a5a5;
-o-box-shadow: 0px 0px 10px #a5a5a5;
-webkit-box-shadow: 0px 0px 10px #a5a5a5;
box-shadow: 0px 0px 10px #a5a5a5;
}
.radius {
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
}
header {
background-color: #e3ffe3;
}
#t1 {
.shadow;
.transition;
}
#t2 {
}
but the style doesn’t work and I don’t know why. I used inspect element tool of chrome and found this exception:
XMLHttpRequest cannot load file:///E:/Projects/Web/Less%20Learning/1.less. Cross origin requests are only supported for HTTP.
Uncaught Error: NETWORK_ERR: XMLHttpRequest Exception 101
I don’t know what does it mean. I want to know how can I resolve my problem.
1. Use a Web Server
You need to actually run a webserver (wamp, nginx, apache), and make the get request to a URI on that server, rather than making the GET request to a file; e.g. change the line:
to read something like:
…also create file names without spaces for better organisation, example:
and the initial request page needs to be made over HTTP as well.
You may also have to set
allow_url_include = Onin the server configuration in php.ini – not usually the case with nginx etc.2. Cleaner folders
Instead of
Projects / Web / Less LearningTry,
Projects / Web / LessAnd inside that: