向所有人问好。你好。我试过用光滑的滑块制作滑块动画。我想更改悬停在缩略图上的主图像。我想问,这可能吗?我在codepen链接(codepan(中添加了我的代码,所以请检查此链接。提前谢谢。尝试这个链接,因为它显示错误,所以我共享我的代码。
jQuery(document).ready(function($) {
$('.slider-for').slick({
slidesToShow: 1,
slidesToScroll: 1,
arrows: false,
fade: true,
asNavFor: '.slider-nav'
});
$('.slider-nav').slick({
slidesToShow: 6,
slidesToScroll: 1,
asNavFor: '.slider-for',
dots: false,
focusOnSelect: true,
responsive: [{
breakpoint: 992,
settings: {
vertical: false,
}
},
{
breakpoint: 768,
settings: {
vertical: false,
}
},
{
breakpoint: 580,
settings: {
vertical: false,
slidesToShow: 3,
}
},
{
breakpoint: 380,
settings: {
vertical: false,
slidesToShow: 2,
}
}
]
});
});
<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css'>
<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick.min.css'><link rel="stylesheet" href="./style.css">
<section class="banner-section">
<div class="container">
<div class="vehicle-detail-banner banner-content clearfix">
<div class="banner-slider">
<div class="slider slider-for">
<div class="slider-banner-image">
<img src="https://images.unsplash.com/photo-1570942872213-1242607a35eb?ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=60" alt="Car-Image">
</div>
<div class="slider-banner-image">
<img src="https://images.unsplash.com/photo-1570171278960-d6c2b316f3b1?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80" alt="Car-Image">
</div>
<div class="slider-banner-image">
<img src="https://images.unsplash.com/photo-1564376130023-5360fbb7c91b?ixlib=rb-1.2.1&auto=format&fit=crop&w=724&q=80" alt="Car-Image">
</div>
<div class="slider-banner-image">
<img src="https://images.unsplash.com/photo-1570942872213-1242607a35eb?ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=60" alt="Car-Image">
</div>
<div class="slider-banner-image">
<img src="https://images.unsplash.com/photo-1570171278960-d6c2b316f3b1?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80" alt="Car-Image">
</div>
<div class="slider-banner-image">
<img src="https://images.unsplash.com/photo-1564376130023-5360fbb7c91b?ixlib=rb-1.2.1&auto=format&fit=crop&w=724&q=80" alt="Car-Image">
</div>
<div class="slider-banner-image">
<img src="https://images.unsplash.com/photo-1570942872213-1242607a35eb?ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=60" alt="Car-Image">
</div>
<div class="slider-banner-image">
<img src="https://images.unsplash.com/photo-1570171278960-d6c2b316f3b1?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80" alt="Car-Image">
</div>
<div class="slider-banner-image">
<img src="https://images.unsplash.com/photo-1564376130023-5360fbb7c91b?ixlib=rb-1.2.1&auto=format&fit=crop&w=724&q=80" alt="Car-Image">
</div>
</div>
<div class="slider slider-nav thumb-image">
<div class="thumbnail-image">
<div class="thumbImg">
<img src="https://images.unsplash.com/photo-1570942872213-1242607a35eb?ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=60" alt="slider-img">
</div>
</div>
<div class="thumbnail-image">
<div class="thumbImg">
<img src="https://images.unsplash.com/photo-1570171278960-d6c2b316f3b1?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80" alt="slider-img">
</div>
</div>
<div class="thumbnail-image">
<div class="thumbImg">
<img src="https://images.unsplash.com/photo-1564376130023-5360fbb7c91b?ixlib=rb-1.2.1&auto=format&fit=crop&w=724&q=80" alt="slider-img">
</div>
</div>
<div class="thumbnail-image">
<div class="thumbImg">
<img src="https://images.unsplash.com/photo-1570942872213-1242607a35eb?ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=60" alt="slider-img">
</div>
</div>
<div class="thumbnail-image">
<div class="thumbImg">
<img src="https://images.unsplash.com/photo-1570171278960-d6c2b316f3b1?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80" alt="slider-img">
</div>
</div>
<div class="thumbnail-image">
<div class="thumbImg">
<img src="https://images.unsplash.com/photo-1564376130023-5360fbb7c91b?ixlib=rb-1.2.1&auto=format&fit=crop&w=724&q=80" alt="slider-img">
</div>
</div>
<div class="thumbnail-image">
<div class="thumbImg">
<img src="https://images.unsplash.com/photo-1570942872213-1242607a35eb?ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=60" alt="slider-img">
</div>
</div>
<div class="thumbnail-image">
<div class="thumbImg">
<img src="https://images.unsplash.com/photo-1570171278960-d6c2b316f3b1?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80" alt="slider-img">
</div>
</div>
<div class="thumbnail-image">
<div class="thumbImg">
<img src="https://images.unsplash.com/photo-1564376130023-5360fbb7c91b?ixlib=rb-1.2.1&auto=format&fit=crop&w=724&q=80" alt="slider-img">
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick.min.js'></script><script src="./script.js"></script>
你好,是的,你可以更改悬停在缩略图上的光滑滑块。您可以对光滑的幻灯片调用鼠标悬停函数。创建一个条件,如果鼠标悬停在光滑的导航(缩略图(上,则更改当前活动的目标。希望这对你有帮助。我编辑了你的代码。
jQuery(document).ready(function($) {
$('.slider-for').slick({
slidesToShow: 1,
slidesToScroll: 1,
arrows: false,
fade: true,
asNavFor: '.slider-nav'
});
//set active class to first slide
$('.slider-nav .slick-slide').eq(0).addClass('slick-active');
$('.slider-nav').slick({
slidesToShow: 6,
slidesToScroll: 1,
asNavFor: '.slider-for',
dots: false,
focusOnSelect: true,
responsive: [{
breakpoint: 992,
settings: {
vertical: false,
}
},
{
breakpoint: 768,
settings: {
vertical: false,
}
},
{
breakpoint: 580,
settings: {
vertical: false,
slidesToShow: 3,
}
},
{
breakpoint: 380,
settings: {
vertical: false,
slidesToShow: 2,
}
}
]
});
$('.slider-nav').on('mouseover', '.slick-slide', function (e) {
var $currTarget = $(e.currentTarget),
index = $currTarget.data('slick-index'),
slickObj = $('.slider-for').slick('getSlick');
slickObj.slickGoTo(index);
});
});
.banner-slider .slider.slider-for {
max-width: 100%;
}
.banner-slider .slider.slider-nav {
max-width: 100%;
}
.banner-slider .slider.slider-for,
.banner-slider .slider.slider-nav {
width: 100%;
}
.banner-slider .slider.slider-for{
padding: 0 5px;
}
.banner-slider .slick-slide img {
width: 100%;
}
.banner-slider .slider-banner-image {
height: auto;
width: 100%;
}
.banner-slider .slider.slider-nav {
padding: 20px 0 0;
}
.banner-slider .slider-nav .slick-slide.thumbnail-image .thumbImg img {
height: 100%;
width:100%;
object-fit: cover;
}
.banner-slider .slider-banner-image img {
width: 100%;
height: 350px;
object-fit: cover;
}
.banner-slider .slick-vertical .slick-slide:active,
.banner-slider .slick-vertical .slick-slide:focus,
.banner-slider .slick-arrow:hover,
.banner-slider .slick-arrow:focus {
border: 0;
outline: 0;
}
.banner-slider .slider-nav .slick-slide.slick-current span {
color: #196DB6;
}
.banner-slider .slider-nav .slick-slide {
text-align: center;
}
.banner-slider .slider-nav .slick-slide span {
font-size: 14px;
display: block;
padding: 5px 0 15px;
}
.banner-slider .slick-arrow {
width: 100%;
background-color: transparent;
border: 0;
background-position: center;
background-repeat: no-repeat;
font-size: 0;
height: 18px;
position: absolute;
left: 0;
right: 0;
z-index: 99;
}
.slick-prev {
top: 0;
}
.slick-next {
bottom: 0;
background-color: #fff;
}
.banner-slider .slider.slider-nav .thumbImg {
padding: 0 5px 15px;
}
.slider-nav .slick-slide.slick-current.slick-active .thumbImg img {
border: 1px solid #80D6CF;
border-radius: 2px;
background-color: #FFFFFF;
box-shadow: 0 0 2px 0 rgba(0,0,0,0.1), 0 2px 4px 0 rgba(0,0,0,0.1);
padding: 3px;
}
@media screen and (max-width : 991px) {
.banner-slider .slider.slider-for,
.banner-slider .slider.slider-nav {
max-width: 100%;
float: none;
}
.banner-slider .slider.slider-for {
padding-right: 0;
}
.banner-slider .slider.slider-nav {
height: auto;
}
.slider-banner-image {
height: 500px;
}
.slider.slider-nav.thumb-image {
padding: 10px 30px 0;
}
.slider-nav .slick-slide span {
padding: 5px 0;
}
.slick-arrow {
padding: 0;
width: 30px;
height: 30px;
top: 50%;
bottom: 0;
-webkit-transform: translateY(-50%) rotate(-90deg);
-moz-transform: translateY(-50%) rotate(-90deg);
-ms-transform: translateY(-50%) rotate(-90deg);
transform: translateY(-50%) rotate(-90deg);
}
.slick-prev {
left: 0;
right: unset;
}
.slick-next {
left: unset;
right: 0;
background-color: transparent;
}
.vehicle-detail-banner .car-slider-desc {
max-width: 340px;
}
.bid-tag {
padding: 10px 0 15px;
}
.slider.slider-nav.thumb-image {
white-space: nowrap;
}
.thumbnail-image.slick-slide {
padding: 0px 5px;
min-width: 75px;
display: inline-block;
float: none;
}
}
@media screen and (max-width : 767px) {
.slider-banner-image {
height: 400px;
}
.slider.slider-nav.thumb-image {
padding: 0px 20px 0;
margin: 10px 0px 0;
}
.slider-nav .slick-slide.thumbnail-image .thumbImg {
max-width: 140px;
height: 80px;
}
.slick-prev.slick-arrow {
background-position: center 10px;
}
.slick-next.slick-arrow {
background-position: center 10px, center;
}
.slider-nav .slick-slide span {
font-size: 12px;
white-space: normal;
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick.min.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick.min.js"></script>
<section class="banner-section">
<div class="container">
<div class="vehicle-detail-banner banner-content clearfix">
<div class="banner-slider">
<div class="slider slider-for">
<div class="slider-banner-image">
<img src="https://images.unsplash.com/photo-1570942872213-1242607a35eb?ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=60" alt="Car-Image">
</div>
<div class="slider-banner-image">
<img src="https://images.unsplash.com/photo-1570171278960-d6c2b316f3b1?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80" alt="Car-Image">
</div>
<div class="slider-banner-image">
<img src="https://images.unsplash.com/photo-1564376130023-5360fbb7c91b?ixlib=rb-1.2.1&auto=format&fit=crop&w=724&q=80" alt="Car-Image">
</div>
<div class="slider-banner-image">
<img src="https://images.unsplash.com/photo-1570942872213-1242607a35eb?ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=60" alt="Car-Image">
</div>
<div class="slider-banner-image">
<img src="https://images.unsplash.com/photo-1570171278960-d6c2b316f3b1?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80" alt="Car-Image">
</div>
<div class="slider-banner-image">
<img src="https://images.unsplash.com/photo-1564376130023-5360fbb7c91b?ixlib=rb-1.2.1&auto=format&fit=crop&w=724&q=80" alt="Car-Image">
</div>
<div class="slider-banner-image">
<img src="https://images.unsplash.com/photo-1570942872213-1242607a35eb?ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=60" alt="Car-Image">
</div>
<div class="slider-banner-image">
<img src="https://images.unsplash.com/photo-1570171278960-d6c2b316f3b1?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80" alt="Car-Image">
</div>
<div class="slider-banner-image">
<img src="https://images.unsplash.com/photo-1564376130023-5360fbb7c91b?ixlib=rb-1.2.1&auto=format&fit=crop&w=724&q=80" alt="Car-Image">
</div>
</div>
<div class="slider slider-nav thumb-image">
<div class="thumbnail-image">
<div class="thumbImg">
<img src="https://images.unsplash.com/photo-1570942872213-1242607a35eb?ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=60" alt="slider-img">
</div>
</div>
<div class="thumbnail-image">
<div class="thumbImg">
<img src="https://images.unsplash.com/photo-1570171278960-d6c2b316f3b1?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80" alt="slider-img">
</div>
</div>
<div class="thumbnail-image">
<div class="thumbImg">
<img src="https://images.unsplash.com/photo-1564376130023-5360fbb7c91b?ixlib=rb-1.2.1&auto=format&fit=crop&w=724&q=80" alt="slider-img">
</div>
</div>
<div class="thumbnail-image">
<div class="thumbImg">
<img src="https://images.unsplash.com/photo-1570942872213-1242607a35eb?ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=60" alt="slider-img">
</div>
</div>
<div class="thumbnail-image">
<div class="thumbImg">
<img src="https://images.unsplash.com/photo-1570171278960-d6c2b316f3b1?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80" alt="slider-img">
</div>
</div>
<div class="thumbnail-image">
<div class="thumbImg">
<img src="https://images.unsplash.com/photo-1564376130023-5360fbb7c91b?ixlib=rb-1.2.1&auto=format&fit=crop&w=724&q=80" alt="slider-img">
</div>
</div>
<div class="thumbnail-image">
<div class="thumbImg">
<img src="https://images.unsplash.com/photo-1570942872213-1242607a35eb?ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=60" alt="slider-img">
</div>
</div>
<div class="thumbnail-image">
<div class="thumbImg">
<img src="https://images.unsplash.com/photo-1570171278960-d6c2b316f3b1?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80" alt="slider-img">
</div>
</div>
<div class="thumbnail-image">
<div class="thumbImg">
<img src="https://images.unsplash.com/photo-1564376130023-5360fbb7c91b?ixlib=rb-1.2.1&auto=format&fit=crop&w=724&q=80" alt="slider-img">
</div>
</div>
</div>
</div>
</div>
</div>
</section>