Keep background image fixed during scroll using css

后端 未结 3 851
一生所求
一生所求 2020-12-01 02:37

How do I keep the background image fixed during a page scroll? I have this CSS code, and the image is a background of the body and not

<
相关标签:
3条回答
  • 2020-12-01 03:14
    background-attachment: fixed;
    

    http://www.w3.org/TR/CSS21/colors.html#background-properties

    0 讨论(0)
  • 2020-12-01 03:16
    background-image: url("/your-dir/your_image.jpg");
    min-height: 100%;
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-position: center;
    background-size: cover;}
    
    0 讨论(0)
  • 2020-12-01 03:21

    Just add background-attachment to your code

    body {
        background-position: center;
        background-image: url(../images/images5.jpg);
        background-attachment: fixed;
    }
    
    0 讨论(0)
提交回复
热议问题