gpt4 book ai didi

javascript - HTML div 格式 : three images that dynamically match viewport size (image slider)

转载 作者:行者123 更新时间:2023-11-27 23:58:14 25 4
gpt4 key购买 nike

我刚开始编写 HTML 和 CSS,但我正处于创建网站的最后一步。即,驻留在后台的图像 slider 。

The Issue: The pictures are not centered respective to the viewport. The first image, for example, should have some padding on the left and should be vertically aligned so as not to move when the height of the image increases to match the viewport height. It should remain centered behind the body of the page.

新问题:当第一个图像的宽度超过视口(viewport)时,图像开始偏离中心,因为它们被锁定在父类/视口(viewport)的左侧。是否存在允许子类元素扩展到父类边界之外的属性?

你们中的一些聪明的网络开发人员能帮我解决这个问题吗?

CodePen完整版网址:CodePen Link

请转到“全 View ”,最小化浏览器并缩短其宽度以了解我的意思。

这是我的 slider HTML 代码:

<!-- Inside <html></html> and below <head></head> -->

<div class="background_carousel">
<div class="carousel_slides">
<div class="slide">
<img src="./img/slideshow/s%20(1).jpg">
</div>

<div class="slide">
<img src="./img/slideshow/s%20(2).jpg">
</div>

<div class="slide">
<img src="./img/slideshow/s%20(3).jpg">
</div>
</div>
</div>

还有我的 slider CSS...

.carousel_slides {
display: flex;
background-color: #999999;
width: max-content;
text-align: center;
}

.carousel_slides .slide {
position: static;
height: 100vh;
width: 100vw;
}

.slide img{
height: 100%;
}

非常感谢您。

最佳答案

使用位置和动态向左调整

关于javascript - HTML div 格式 : three images that dynamically match viewport size (image slider),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56141466/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com