简体   繁体   English

Parallax.js 中的缩放图像

[英]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.我提前为我的英语道歉,我在我的页面上使用 Parallax.js,我遇到了以下问题。 The picture that I use to create the parallax has a resolution of 3160x2840 but my screen is 1920x1080.我用来创建视差的图片的分辨率是 3160x2840,但我的屏幕是 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这是一个技巧,为您的 img 标签指定 class="parallax-image"

.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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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