javascript - How can I get height of any element using LESS? - Stack Overflow

How can I get height of any element using LESS?<html><head><title><title><

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

Share Improve this question edited Aug 5, 2014 at 10:43 4dgaurav 11.5k4 gold badges34 silver badges59 bronze badges asked Aug 5, 2014 at 10:24 RomanRoman 51 silver badge2 bronze badges 1
  • This is not possible in LESS. See this answer. – knuckfubuck Commented Aug 5, 2014 at 10:30
Add a ment  | 

1 Answer 1

Reset to default 7

Since 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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742408825a4438398.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信