我有如下所示的CSS,在PC浏览器中进行响应时,我已经使用响应式设计模式对其进行了正常测试,但是当我在手机上进行测试时,背景没有响应:
.imgBG {
background: url(../../../assets/img/bg-img/bg-login-blur.jpg) no-repeat center center fixed;
font-family: Open Sans;
padding-top: 40px;
padding-bottom: 40px;
position: fixed;
width:100%;
height:100%;
background-size:cover;
background-position:center;
background-repeat:no-repeat;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
padding:20px;
}
我想念的是什么,您能告诉我吗?
将此行添加到代码中:background-attachment: fixed;
使用此代码。
.imgBG {
background-image: url(../../../assets/img/bg-img/bg-login-blur.jpg);
background-repeat: no-repeat;
background-position: center;
background-size: cover;
width: 100%;
height: 100%;
}
将其添加到您的HTML标头中:
<meta name="viewport" content="width=device-width, initial-scale=1.0">