美文网首页
如何解决IOS中background-attachment不兼容

如何解决IOS中background-attachment不兼容

作者: 灰太狼_8502 | 来源:发表于2017-09-15 11:13 被阅读0次

近日开发人和APP项目的时候,遇到一个之前没有想到过的一个问题,background-attachment在ios系统上面不兼容,作为一个前端开发最怕遇到,最难解决的也就是这种兼容问题了。还好想到了一个代替解决的办法:
利用伪类before,代码如下;

body:before{
    content: '';
    position: fixed;
    z-index: -1;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: url(../img/aboutus/aubg.png) center 0 no-repeat;
    background-size: cover; 
}

而在body里面做这样的处理,代码如下:

body{
    display: block;
    position: absolute;
    left: 0;
    top: 0;
    z-index: 10;
    width: 100%;
    
}

这个解决办法并不难,大家应该也容易想到,希望能帮到大家!

相关文章

网友评论

      本文标题:如何解决IOS中background-attachment不兼容

      本文链接:https://www.haomeiwen.com/subject/thdssxtx.html