gpt4 book ai didi

html - 使用 css(Slick Carousel 库)在同一底部对齐图像 slider

转载 作者:太空宇宙 更新时间:2023-11-04 09:37:35 26 4
gpt4 key购买 nike

我使用 slick carousel 库创建了一个 sublime slider ,但是使用不同高度的图像并没有使图像在同一底部对齐:

enter image description here

我的代码:

<html lang="en">

<head>
<title>slick - the last carousel you'll ever need</title>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="http://kenwheeler.github.io/slick/slick/slick.js"></script>
<link rel="stylesheet" type="text/css" href="http://kenwheeler.github.io/slick/slick/slick.css" />
</head>

<body>
<div class="slider responsive">
<div><img src="http://url/Public/Publications/856518/1916982/Images/Detail.jpg"></div>
<div><img src="http://url/Public/Publications/101506/1917549/Images/Detail.jpg"></div>
<div><img src="http://url/Public/Publications/678542/1917100/Images/Detail.jpg"></div>
<div><img src="http://url/Public/Publications/1658142/1917547/Images/Detail.jpg"></div>
<div><img src="http://cdn1.lekiosk.com/Public/Publications/596057/1911177/Images/Detail.jpg"></div>
<div><img src="http://url/Public/Publications/286869/1917506/Images/Detail.jpg"></div>
<div><img src="http://url/Public/Publications/678542/1917100/Images/Detail.jpg"></div>
<div><img src="http://url/Public/Publications/856518/1916982/Images/Detail.jpg"></div>
</div>
</body>
<script type="text/javascript">
$(".responsive").not('.slick-initialized').slick({
dots: false,
infinite: true,
speed: 500,
arrows: false,
slidesToShow: 5,
slidesToScroll: 2,
responsive: [{
breakpoint: 1024,
settings: {
slidesToShow: 5,
slidesToScroll: 3,
infinite: true,
arrows: false,
dots: false
}
}, {
breakpoint: 600,
settings: {
slidesToShow: 4,
slidesToScroll: 2,
arrows: false,
dots: false,
infinite: true
}
}, {
breakpoint: 480,
settings: {
slidesToShow: 3,
slidesToScroll: 1,
arrows: false,
infinite: true,
dots: false
}
}]
});
</script>

</html>

我不想使用媒体查询为每个屏幕分辨率设置高度值。有什么想法吗?

最佳答案

这是您的问题的解决方案。我不会说它是最好的,但它可以完成工作。所以你实际上可以做的是使用 max-height 的 css 规则分别引用每个图像。我指定每张图片都应具有 style ="max-height:300px;",这样它们就可以达到相同的高度。以下是我如何更改您的代码:

    <div class="slider responsive">
<div><img src="http://cdn1.lekiosk.com/Public/Publications/856518/1916982/Images/Detail.jpg"style ="max-height:300px;"></div>
<div><img src="http://cdn1.lekiosk.com/Public/Publications/101506/1917549/Images/Detail.jpg" style ="max-height:300px;"></div>
<div><img src="http://cdn1.lekiosk.com/Public/Publications/678542/1917100/Images/Detail.jpg"style ="max-height:300px;"></div>
<div><img src="http://cdn1.lekiosk.com/Public/Publications/1658142/1917547/Images/Detail.jpg" style ="max-height:300px;"></div>
<div><img src="http://cdn1.lekiosk.com/Public/Publications/596057/1911177/Images/Detail.jpg" style ="max-height:300px;"></div>
<div><img src="http://cdn1.lekiosk.com/Public/Publications/286869/1917506/Images/Detail.jpg" style ="max-height:300px;"></div>
<div><img src="http://cdn1.lekiosk.com/Public/Publications/678542/1917100/Images/Detail.jpg" style ="max-height:300px;"></div>
<div><img src="http://cdn1.lekiosk.com/Public/Publications/856518/1916982/Images/Detail.jpg" style ="max-height:300px;"></div>
</div>

这是一个带有 Bootstrap 的旋转木马 slider ,其中所有图像的高度都相同。请随时查看:

Carousel Slider Bootstrap

这不是最优雅的解决方案,但它可以完成工作。告诉我它是否对你有用。

New Fiddle #2

关于html - 使用 css(Slick Carousel 库)在同一底部对齐图像 slider ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40206733/

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