admin管理员组文章数量:1336645
How can I get height of any element using LESS?
<html>
<head>
<title></title>
<style>
html, body {
height: 100%;
}
header {
height: auto;
text-align: center;
background: red;
}
@windowHeight: `$(window).height()`;
@headerHeight: `$('header').height()`; /* NOT WORKING */
@sectionHeight: @windowHeight - @headerHeight;
section {
height: ~'@{sectionHeight}px';
text-align: center;
background: green;
}
</style>
</head>
<body>
<header>TITLE<header>
<section>TEXT</section>
</body>
</html>
How can I get height of any element using LESS?
Example if I set <header>
height = 100px
, then this code is working
How can I get height of any element using LESS?
<html>
<head>
<title></title>
<style>
html, body {
height: 100%;
}
header {
height: auto;
text-align: center;
background: red;
}
@windowHeight: `$(window).height()`;
@headerHeight: `$('header').height()`; /* NOT WORKING */
@sectionHeight: @windowHeight - @headerHeight;
section {
height: ~'@{sectionHeight}px';
text-align: center;
background: green;
}
</style>
</head>
<body>
<header>TITLE<header>
<section>TEXT</section>
</body>
</html>
How can I get height of any element using LESS?
Example if I set <header>
height = 100px
, then this code is working
- This is not possible in LESS. See this answer. – knuckfubuck Commented Aug 5, 2014 at 10:30
1 Answer
Reset to default 7Since LESS processes your styles BEFORE the CSS gets delivered and interpreted by the browser there is no way you can let it do the math after that. The information needed is rendered way later, so you will have to either include a JS to modify the DOM after loading or make JS build the section in the first place.
本文标签: javascriptHow can I get height of any element using LESSStack Overflow
版权声明:本文标题:javascript - How can I get height of any element using LESS? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742408825a2469372.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论