如题, 最开始我使用的是position:fixed 发现在两种设备上都无效,后来百度改用 background-attachment:fixed ,在安卓中效果正常,可到了IOS上又完蛋了。
我知道UI设计的开发中, 背景固定是很常用的一个显示方法,求大佬们指点一二如何解决,很急
首先我从网上找到的都是这个版本:
body:before {
content: ' ';
position: fixed;
z-index: -1;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: url(path/to/image) center 0 no-repeat;
background-size: cover;
}
后来我发现没什么作用
你直接在dom元素里面写background不用把他们分级
我就用的下方的样式,完全好用哦,样式放在最外层
.content {
position:fixed;
top:0;
left:0;
width:100%;
height:100%;
background:url('https://dfsn.china-tengyun.com/group1/M00/01/60/cH5Z71tsCSyAbaJdAACoXp7ghWs919.jpg') no-repeat #000;
background-size:cover;
z-index:-1;
}