简体   繁体   中英

Repeat-y is not working for me. The image is not repeating as it should

I have a simple html code below

<body>
    <div class="wrapper">
        <div class="container">
            <div class="sky"></div>
            <img src="images/arcade-game.png" alt="">
        </div>
        
    </div>
</body>

and here is my CSS code

.container{
    height:90vh;
    width:90vw;
    background-color: white;
    margin: auto auto;
    position: relative;
    overflow:hidden;
    
}

.sky{
    height: 100%;
    width: 100%;
    background-image: url(/images/sky.jpg);
    background-size: cover;
    background-repeat: repeat-y;
    animation: movingsky 4s linear infinite;

} 

I have the animation for the .sky to move downwards, however the background isn't repeating as how I wanted it to be.

Am i missing anything here?

background-size: cover; will stretch the image to fill the entire container, therefore no repetitions are visible. Either remove background-size or set it to a fixed size.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM