Answer the question
In order to leave comments, you need to log in
LESS and document.body.clientWidth - why doesn't it work?
I can hardly restrain myself so as not to express my emotions with obscenities. I've been suffering for a couple of hours now.
I have the following HTML code
<!DOCTYPE html>
<html>
<head>
<title>Тестовый проект</title>
<meta charset="UTF-8" />
<link rel="stylesheet/less" type="text/css" href="styles.less">
<script type="text/javascript" src="http://lesscss.googlecode.com/files/less-1.3.0.min.js"></script>
</head>
<body>
<div class="metroContent">Проверка</div>
</body>
</html>
html {height: 100%; width: 100%;}
body {background: #6ab56e; width: 100%; height: 100%;}
@pro: `document.body.clientWidth`;
.metroContent {margin-left: @pro;}
Answer the question
In order to leave comments, you need to log in
When checking your code, I get the error "TypeError: document.body is null", which is quite logical.
As a crutch, you can execute less.js after the page has loaded:
$(document).ready(function()
{
$.getScript('http://lesscss.googlecode.com/files/less-1.3.0.min.js');
});
.metroContent:after
{
content: "@{pro}";
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question