安卓5版本使用position为absolute定位宽度为100%左边空白

495 阅读1分钟

bug代码

.bg-container {
     position: absolute;
     top: 0;
     width: 100%;
     bottom: 0;
     background-image: url(../../../images/xxx.png);
     background-size: cover;
 }    

导致左边空白

解决方案

使用left为0和right为0等传统布局方案解决问题

.bg-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url(../../../images/xxx.png);
    background-size: cover;
}