gpt4 book ai didi

jquery - 带标签的 slider

转载 作者:行者123 更新时间:2023-11-27 22:54:59 27 4
gpt4 key购买 nike

我有一个带有文本和相关背景图像的 slider 选项卡。当我点击 slider 选项卡时,相关图像应该可以通过滑动动画看到。问题出现在 slider 图像中,当我再次单击它不显示的图像时,如果条件不起作用。 `

HTML:

<div class="ce-slider-wrapper">
<div class="ce-slider-images-wrapper" id="csw">
<div class="ce-slider-image active-frame" id="ce-img1C">
<img src="https://cdn2.hubspot.net/hubfs/5215930/core-experience/svasahome.png" alt="Core Experience">
</div>
<div class="ce-slider-image" id="ce-img2C">
<img src="https://cdn2.hubspot.net/hubfs/5215930/core-experience/Livingroom%20Classic%201.png" alt="Core Experience">
</div>
<div class="ce-slider-image" id="ce-img3C">
<img src="https://cdn2.hubspot.net/hubfs/5215930/core-experience/indivillage.png" alt="Core Experience">
</div>
</div>
<div class="ce-slider-thumbs" id="ce-thumbs">
<div class="ce-slider-content">
<div class="ce-desc" id="ce-img1">
<div class="ce-desc-subheading">
<div class="ce-desc-line"></div>
<p>01 / SVASA HOMES</p>
</div>
<div class="ce-desc-text">
<p>The Revival of Ancient Wisdom</p>
</div>
</div>
</div>
<div class="ce-slider-content">
<div class="ce-desc" id="ce-img2">
<div class="ce-desc-subheading">
<div class="ce-desc-line"></div>
<p>02 / VAYATHI WEAVES</p>
</div>
<div class="ce-desc-text">
<p>Weaving A Grand New Story</p>
</div>
</div>
</div>
<div class="ce-slider-content">
<div class="ce-desc" id="ce-img3">
<div class="ce-desc-subheading">
<div class="ce-desc-line"></div>
<p>03 / THOTA</p>
</div>
<div class="ce-desc-text">
<p>Uplifting Farmers From The Ground Up</p>
</div>
</div>
</div>
</div>
</div>

jQuery:

$(document).ready(function() {
$('.ce-slider-thumbs').slick({
slidesToShow: 2,
slidesToScroll: 1,
autoplay: true,
infinite: true,
arrows: false,
dots: false,
fade: false,
centerMode: false,
autoplaySpeed: 2000,
focusOnSelect: true,
draggable: false
});

$('#ce-thumbs .ce-desc:not(:first)').addClass('inactive');
$('.ce-slider-image').hide();
$('.active-frame').show();

$('.ce-desc').click(function() {
var css = $(this).attr('id');
if ($(this).hasClass('inactive')) { //this is the start of our condition
$('.ce-desc').addClass('inactive');
$(this).removeClass('inactive');
$(this).addClass('active-tab');
$('.ce-slider-image').hide();
$('#' + css + 'C').css('display', 'block');
}
});

});

CSS:

.ce-slider-wrapper {
width: 100%;
height: 100vh;
position: relative;
}

.ce-slider-image {
width: 100%;
height: 100vh;
}

.ce-slider-image img {
width: 100%;
height: 100%;
object-fit: cover;
}

.ce-slider-thumbs {
position: absolute;
bottom: 20px;
left: 0px;
right: 0px;
display: flex;
width: 60%;
margin: auto;
outline: none;
justify-content: space-between;
}

.ce-slider-content {
width: 30%;
color: #fff;
}

.ce-desc {
display: flex;
flex-direction: column;
}

.ce-desc-line {
width: 180px;
height: 5px;
background: #b7b7b7;
opacity: 0.5;
}

.ce-desc-subheading p {
font-size: 14px;
color: #fff;
font-family: arial;
letter-spacing: 0.35rem;
}

.slick-cloned {
display: none;
}

我有一个带有文本和相关背景图像的 slider 选项卡。当我点击 slider 选项卡时,相关图像应该可以通过滑动动画显示。问题出现在 slider 图像中,当我再次单击它显示的图像时,如果条件不起作用,它就没有。

最佳答案

我添加了灵活的 slider 属性“asNavFor”,用于链接主 slider 和 Thumb slider 。

$(document).ready(function() {
$('.ce-slider-thumbs').slick({
slidesToShow: 2,
slidesToScroll: 1,
autoplay: false,
infinite: true,
arrows: false,
dots: false,
fade: false,
centerMode: false,
autoplaySpeed: 2000,
focusOnSelect: true,
draggable: false,
asNavFor: '.ce-slider-images-wrapper'
});

$('.ce-slider-images-wrapper').slick({
slidesToShow: 1,
slidesToScroll: 1,
autoplay: false,
infinite: true,
arrows: false,
dots: false,
fade: true,
useCSS: false,
centerMode: false,
autoplaySpeed: 2000,
focusOnSelect: true,
draggable: false,
asNavFor: '.ce-slider-thumbs'
});

});
.ce-slider-wrapper {
width: 100%;
height: 100vh;
position: relative;
}

.ce-slider-image {
width: 100%;
height: 100vh;
}

.ce-slider-image img {
width: 100%;
height: 100%;
object-fit: cover;
}
.ce-slider-thumbs.slick-slider {
position: absolute;
}
.ce-slider-thumbs {
position: absolute;
bottom: 20px;
left: 0px;
right: 0px;
display: flex;
width: 60%;
margin: auto;
outline: none;
justify-content: space-between;
}

.ce-slider-content {
width: 30%;
color: #fff;
}

.ce-desc {
display: flex;
flex-direction: column;
}

.ce-desc-line {
width: 180px;
height: 5px;
background: #b7b7b7;
opacity: 0.5;
}

.ce-desc-subheading p {
font-size: 14px;
color: #fff;
font-family: arial;
letter-spacing: 0.35rem;
}

.slick-cloned {
display: none;
}

/*== Add this extra CSS ==*/
.ce-slider-images-wrapper .slick-slide{
opacity: 0 !important;
}
.ce-slider-images-wrapper .slick-slide.slick-active{
opacity: 1 !important;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick.js"></script>
<div class="ce-slider-wrapper">
<div class="ce-slider-images-wrapper" id="csw">
<div class="ce-slider-image active-frame" id="ce-img1C">
<img src="https://cdn2.hubspot.net/hubfs/5215930/core-experience/svasahome.png" alt="Core Experience">
</div>
<div class="ce-slider-image" id="ce-img2C">
<img src="https://cdn2.hubspot.net/hubfs/5215930/core-experience/Livingroom%20Classic%201.png" alt="Core Experience">
</div>
<div class="ce-slider-image" id="ce-img3C">
<img src="https://cdn2.hubspot.net/hubfs/5215930/core-experience/indivillage.png" alt="Core Experience">
</div>
</div>
<div class="ce-slider-thumbs" id="ce-thumbs">
<div class="ce-slider-content">
<div class="ce-desc" id="ce-img1">
<div class="ce-desc-subheading">
<div class="ce-desc-line"></div>
<p>01 / SVASA HOMES</p>
</div>
<div class="ce-desc-text">
<p>The Revival of Ancient Wisdom</p>
</div>
</div>
</div>
<div class="ce-slider-content">
<div class="ce-desc" id="ce-img2">
<div class="ce-desc-subheading">
<div class="ce-desc-line"></div>
<p>02 / VAYATHI WEAVES</p>
</div>
<div class="ce-desc-text">
<p>Weaving A Grand New Story</p>
</div>
</div>
</div>
<div class="ce-slider-content">
<div class="ce-desc" id="ce-img3">
<div class="ce-desc-subheading">
<div class="ce-desc-line"></div>
<p>03 / THOTA</p>
</div>
<div class="ce-desc-text">
<p>Uplifting Farmers From The Ground Up</p>
</div>
</div>
</div>
</div>
</div>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick.css" />

关于jquery - 带标签的 slider ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56697978/

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