Getting percentages to work in CSS calc() for Firefox and Safari?

后端 未结 3 1229
难免孤独
难免孤独 2021-02-14 02:53

I\'m using the following calc() equation to calculate the width of two divs:

CSS

.MyClass {
    width: calc((100% - 800px) / 2);
    wid         


        
3条回答
  •  半阙折子戏
    2021-02-14 03:37

    The reason for this not working is that the parent element does not have height value defined.

    It is strange but it works for Chrome and it does not need defined height, but that is not the case for Firefox

    If you have:

    put:

    .parent {
        height: 100%;
    }
    

    and it should be ok.

提交回复
热议问题