Setting a length (height or width) for one element minus the variable length of another, i.e. calc(x - y), where y is unknown

后端 未结 6 2312
忘了有多久
忘了有多久 2020-11-28 12:50

I know we can use calc when lengths are defined:

flex-basis: calc(33.33% - 60px);
left: calc(50% - 25px);
height: calc(100em/5);

But what i

6条回答
  •  余生分开走
    2020-11-28 13:08

    IN CSS

    Although I've never tried it, I believe that this would work:

    .top {
        height:13px;
    }
    
    .main {
        height:calc(100% - var(height));
    }
    

    http://www.creativebloq.com/netmag/why-you-need-use-css-variables-91412904


    IN SASS

    $top_height: 50px
    
    .main {
        height: calc(100% - $top_height)
    }
    

    Sass Variable in CSS calc() function

提交回复
热议问题