html - 如何让我的背景在一个固定的位置?

标签 html css ionic-framework background css-position

我使用 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/

相关文章:

html - 我们可以在 HTML5 中使用 <main> 而不是 <div class ="container"> 吗?

html - 带有 div 和 div 的 CSS 在盒子上?

javascript - safari 和 jQuery 的 CSS 填充不加载

javascript - Ionic 3 减少启动时间

ionic-framework - 尝试上传 Ionic App 时获取 "Sorry! The configured backend (pro) does not know about ionic upload"

html - 浏览器的图像全宽

html - Flexbox一长一短列

php - mail() php 不以 html 格式发送

ionic-framework - 如何在所有页面上显示 Ionic Tabs?

javascript - 设置所有 <img> 标签大小