如何固定背景?

时间:2018-06-19 16:31:28

标签: html css ionic-framework background css-position

我使用离子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');
          }

1 个答案:

答案 0 :(得分:0)

您可以使用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>