How to fix vh(viewport unit) css in mobile Safari?

前端 未结 8 1807
慢半拍i
慢半拍i 2020-12-14 16:54

I\'ve used vh (viewport units) css in one of my projects but in mobile safari it doesn\'t work. It seems like Safari doesn\'t know what to do with vh, but it works fine in o

8条回答
  •  粉色の甜心
    2020-12-14 17:31

    I found this library very useful: https://github.com/Hiswe/vh-check

    It will calculate the offset value for the correct vh, and put it in a css variable so you can use it in the css:

    .main {
      height: calc(100vh - var(--vh-offset, 0px));
    }
    

提交回复
热议问题