我使用 ionic 3。 我的背景在移动,我不想让它滚动。 如何让我的背景位置固定?
<style>
#back {
background-size: 100%;
background-repeat: no-repeat!important;
background-size: cover!important;
width: 105vw!important;
height: 100vh!important;
margin-left: -10%!important;
background-attachment: fixed!important;
margin-top: -10%!important;
background-position: center center!important;
}
</style>
#back {
background-size: 100%;
background-repeat: no-repeat;
background-size: cover;
width: 105vw;
height: 105vh;
margin-left: -10%;
background-attachment: fixed;
margin-top: -10%;
background-position: center center;
}
.ion-content {
background: url('../assets/imgs/back.png');
}
最佳答案
您可以使用 position
属性。
<style>
#back {
background-size: 100%;
background-repeat: no-repeat!important;
background-size: cover!important;
width: 105vw!important;
height: 100vh!important;
margin-left: -10%!important;
background-attachment: fixed!important;
margin-top: -10%!important;
background-position: center center!important;
position: fixed;
}
</style>
关于html - 如何让我的背景在一个固定的位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50933069/