简体   繁体   English

需要多个“background-size:cover;”?

[英]Need multiple “background-size: cover;”?

I am trying to build a project for fun and I want to create a page that has multiple images when you scroll down.我正在尝试构建一个有趣的项目,并且我想在您向下滚动时创建一个包含多个图像的页面。 I am using HTML and CSS.我正在使用 HTML 和 CSS。

I want the layout to be similar to background-size: cover;我希望布局类似于background-size: cover; but apparently you can only use 1 per page?但显然你每页只能使用 1 个?

Here is a website with a similar layout I am trying to achieve sample website Minus all the transitions.这是一个布局相似的网站,我正在尝试实现示例网站减去所有转换。 I am just trying to achieve the image layout of this website.我只是想实现这个网站的图像布局。

I can't figure out how to size my images to be similar to the cover layout but I want the page to be able to scroll down not one stacked on top of the other.我不知道如何调整我的图像大小以使其与封面布局相似,但我希望页面能够向下滚动,而不是一个堆叠在另一个之上。

I have tried using background-image: url("sample.jpg"), url("sample2.jpg");我尝试过使用background-image: url("sample.jpg"), url("sample2.jpg"); but they stack the images on top of each other instead of make the page scrollable.但是它们将图像堆叠在一起,而不是使页面可滚动。

I also tried using multiple divs each with their own background-size: cover;我还尝试使用多个 div,每个 div 都有自己的background-size: cover; but only the first photo shows up?但只有第一张照片出现?

I want a vertical scrolling page full of "cover" images if that makes sense?如果有意义,我想要一个充满“封面”图像的垂直滚动页面? I don't know how else to explain it, i've spent hours googling it and I can't find anything?我不知道如何解释它,我花了几个小时在谷歌上搜索它,但我找不到任何东西?

I am still pretty new to web development so I hope I explained everything ok.我对 web 开发还很陌生,所以我希望我能解释一切。 If you need more information just ask me.如果您需要更多信息,请询问我。

You can put <img> tag one by another and give them all the same classname.您可以一个接一个地放置<img>标记,并为它们赋予相同的类名。 And then give然后给
background-size: cover; property to the class. class 的属性。

html and css code html 和 css 代码

        <img src="firstimgae.jpg">
        <img src="secondimage.jpg">
    </div>```

```.photos {
    background-size: cover;
}```

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

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