On Safari Mobile 10.3 sticky footer can be scrolled off the screen

前端 未结 3 2124
走了就别回头了
走了就别回头了 2021-02-11 17:19

Our mobile web application has sticky bottom navigation like the one you often find in iOS applications, and after Safari 10.3 release on landscape only it is p

3条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-11 17:40

    This is more a workaround than a real solution. However position: fixed has been a problem for mobile devices for years and the best way to overcome this problem is to use position: sticky.

    sticky behaves like position: relative within its parent, until a given offset threshold is met in the viewport.

    From: Stick your landings! position: sticky lands in WebKit

    However position: sticky is not fully supported yet, so I would suggest to use also:

    position: sticky; /* currently in development for MS Edge */
    position: -webkit-sticky;
    position: -moz-sticky;
    position: -o-sticky;
    

    See status here for MS Edge sticky support status (thank you Frits)


    html,
    body {
      height: 200%;
    }
    
    body {
      background-image: linear-gradient(180deg, #ededed 0px, #ededed 9px, #000000 9px, #000000 10px);
      background-size: 100% 10px;
    }
    
    footer {
      position: sticky; /* currently in development for MS Edge */
      position: -webkit-sticky;
      position: -moz-sticky;
      position: -o-sticky;
      height: 50px;
      top: 80%;
      background: rgba(255, 0, 0, 0.7);
    }
    
    
    
    
      
      
      JS Bin
    
    
    
      

提交回复
热议问题