每当我滚动页面时,我的背景也会滚动如何解决这个问题?

时间:2018-03-13 09:59:41

标签: css

这是我的css代码

.bg-main {
    background: linear-gradient(0deg,rgba(0,0,0,0.5),rgba(0,0,0,0.5)), url(../img/mother.png) no-repeat center center fixed !important; 
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover !important;
}

1 个答案:

答案 0 :(得分:0)

从其样式中删除fixed

background: linear-gradient(0deg,rgba(0,0,0,0.5),rgba(0,0,0,0.5)), url(../img/mother.png) no-repeat center center !important; 
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover !important;