gpt4 book ai didi

css - 如何使用光滑的 slider 为 slider 图像添加慢速放大效果?

转载 作者:太空宇宙 更新时间:2023-11-03 21:11:59 25 4
gpt4 key购买 nike

我正在尝试复制 slider 在本网站上使用的缓慢放大效果:https://www.palazzokitchens.co.nz/

我正在使用 slick slider,如何实现这种效果?

我尝试过使用 scale(1.5) 进行长过渡,但这也会使其子项也进行缩放。

我已经设置了一个 slider 演示,非常感谢任何帮助:https://codepen.io/ifusion/pen/EvRPOB

最佳答案

使用此代码,请在整页中查看代码。

$(document).ready(function() {
$('.hero-slider').slick({
arrows: false,
autoplay: true,
autoplaySpeed: 3000
});
});
.no-overflow {
overflow: hidden;
}
.columns{
position:relative;
}
.hero-image {
background-repeat: no-repeat;
background-size: cover;
background-position: center center;
height: 550px;
position: relative;
width: 100%;
}
.hero-text {
font-size: 50px;
color: white;;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
text-align: center;
}
.slick-slider { overflow: hidden; }
.slick-slider div.slick-active .hero-image {
-webkit-animation: myMove 8s 1 ease-in-out;
-moz-animation: myMove 8s 1 ease-in-out;
-o-animation: myMove 8s 1 ease-in-out;
-ms-animation: myMove 8s 1 ease-in-out;
animation: myMove 8s 1 ease-in-out;
}
@keyframes myMove {
from { transform: scale(1.0,1.0); transform-origin: 50% 50%; }
to { transform: scale(1.1,1.1); transform-origin: 50% 0%; }
}
@-webkit-keyframes myMove {
from { -webkit-transform: scale(1.0,1.0); -webkit-transform-origin: 50% 50%; }
to { -webkit-transform: scale(1.1,1.1); -webkit-transform-origin: 50% 0%; }
}
@-o-keyframes myMove {
from { -o-transform: scale(1.0,1.0); -o-transform-origin: 50% 50%; }
to { -o-transform: scale(1.1,1.1); -o-transform-origin: 50% 0%; }
}
@-moz-keyframes myMove {
from { -moz-transform: scale(1.0,1.0); -moz-transform-origin: 50% 50%; }
to { -moz-transform: scale(1.1,1.1); -moz-transform-origin: 50% 0%; }
}
@-ms-keyframes myMove {
from { -ms-transform: scale(1.0,1.0); -ms-transform-origin: 50% 50%; }
to { -ms-transform: scale(1.1,1.1); -ms-transform-origin: 50% 0%; }
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.6.0/slick.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.6.0/slick.min.js"></script>
<div class="hero-slider">
<div class="columns">
<div class="hero-image" style="background-image: url('http://lorempixel.com/output/city-q-c-1900-500-6.jpg')">
</div>
<div class="hero-text">Dummy text in here 1</div>
</div>
<div class="columns">
<div class="hero-image" style="background-image: url('http://lorempixel.com/output/technics-q-c-1900-500-8.jpg')">
</div>
<div class="hero-text">Dummy text in here 2</div>
</div>
<div class="columns">
<div class="hero-image" style="background-image: url('http://lorempixel.com/output/nature-q-c-1900-500-5.jpg')">
</div>
<div class="hero-text">Dummy text in here 3</div>
</div>
</div>

关于css - 如何使用光滑的 slider 为 slider 图像添加慢速放大效果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45831233/

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