简体   繁体   中英

Scaling image in Parallax.js

I apologize in advance for my English, I'm using Parallax.js on my page and I ran into the following problem. The picture that I use to create the parallax has a resolution of 3160x2840 but my screen is 1920x1080. Is it possible to make this photo scale to the screen resolution?

here is a trick, specify class="parallax-image" to your img tag

.parallax-image {
    position: absolute;
    top: 50%;
    left: 50%;
    -ms-transform: translate(-50%, -50%);
    -webkit-transform: translate(-50%, -50%);
    -moz-transform: translate(-50%, -50%);
    -o-transform: translate(-50%, -50%);
    transform: translate(-50%, -50%);
}

other way you can use

width: 100vw

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