gpt4 book ai didi

jquery - 猫头鹰轮播缩略图

转载 作者:行者123 更新时间:2023-11-28 02:26:34 25 4
gpt4 key购买 nike

因此,我创建了一个图像轮播,然后为其缩略图创建了另一个轮播,因为缩略图与轮播中的图像不同。现在我的问题是在尝试通过单击缩略图来更改图像时。

对于缩略图功能,我使用了这个插件:https://github.com/gijsroge/OwlCarousel2-Thumbs

这是我的设置:

<div class="owl-carousel main-carousel" data-slider-id="1">
<div>Your Content</div>
<div>Your Content</div>
<div>Your Content</div>
<div>Your Content</div>
</div>
<div class="owl-thumbs owl-carousel" data-slider-id="1">
<button class="owl-thumb-item">slide 1</button>
<button class="owl-thumb-item">slide 2</button>
<button class="owl-thumb-item">slide 3</button>
<button class="owl-thumb-item">slide 4</button>
</div>

最佳答案

您的答案链接在这里:https://codepen.io/olgaysezgin/pen/JBdrxE

$(document).ready(function() {
$(".owl-carousel").owlCarousel({

items: 1,


});
});


// the following to the end is whats needed for the thumbnails.
jQuery(document).ready(function() {


// 1) ASSIGN EACH 'DOT' A NUMBER
dotcount = 1;

jQuery('.owl-dot').each(function() {
jQuery(this).addClass('dotnumber' + dotcount);
jQuery(this).attr('data-info', dotcount);
dotcount = dotcount + 1;
});

// 2) ASSIGN EACH 'SLIDE' A NUMBER
slidecount = 1;

jQuery('.owl-item').not('.cloned').each(function() {
jQuery(this).addClass('slidenumber' + slidecount);
slidecount = slidecount + 1;
});

// SYNC THE SLIDE NUMBER IMG TO ITS DOT COUNTERPART (E.G SLIDE 1 IMG TO DOT 1 BACKGROUND-IMAGE)
jQuery('.owl-dot').each(function() {

grab = jQuery(this).data('info');

slidegrab = jQuery('.slidenumber' + grab + ' img').attr('src');
console.log(slidegrab);

jQuery(this).css("background-image", "url(" + slidegrab + ")");

});

// THIS FINAL BIT CAN BE REMOVED AND OVERRIDEN WITH YOUR OWN CSS OR FUNCTION, I JUST HAVE IT
// TO MAKE IT ALL NEAT
amount = jQuery('.owl-dot').length;
gotowidth = 100 / amount;

jQuery('.owl-dot').css("width", gotowidth + "%");
newwidth = jQuery('.owl-dot').width();
jQuery('.owl-dot').css("height", newwidth + "px");



});
html {
height: 100%;
width: 100%;
}

.slide-cont {
width: 600px;
display: block;
margin: 0 auto;
}

.owl-carouse div {
width: 100%;
}


/*SEE END OF THUMBNAIL FUCNTION TO TINKER SIZE OF THUMBS*/

.owl-carousel .owl-controls .owl-dot {
float: left;
background-size: cover;
margin-top: 10px;
}


/* BELOW THIS IS JUST MY OWN BACKGROUND ETC AND ISN'T NEEDED */

body {
background-color: #1f1f1f;
background: -webkit-radial-gradient(#1f1f1f, #000000);
background: radial-gradient(#1f1f1f, #000000);
}

h1 {
font-family: 'Open Sans', sans-serif;
font-size: 30px;
color: #fff;
text-align: center;
position: absolute;
width: 100%;
top: 0px;
background: #000;
margin: 0px;
padding: 15px 0px;
z-index: 200;
}

.owl-carousel .owl-dot {
float: left;
background-size: cover;
}
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.1.6/owl.carousel.min.js"></script>
<!-- STYLE FOR H1 TAG -->
<link href='https://fonts.googleapis.com/css?family=Open+Sans:700' rel='stylesheet' type='text/css'>
<!-- ESSENTIAL OWL CARO CSS FILE -->
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.1.6/assets/owl.carousel.min.css">
</head>

<h1>Owl Carousel 2 Thumbnails</h1>


<div class="slide-cont">
<div class="owl-carousel">
<div><img src="http://imew.co.uk/wp-content/uploads/2017/03/cav1-1.png"></div>
<div><img src="http://imew.co.uk/wp-content/uploads/2017/03/cav2-1.png"></div>
<div><img src="http://imew.co.uk/wp-content/uploads/2017/03/cav3-1.png"></div>
<div> <img src="http://imew.co.uk/wp-content/uploads/2017/03/cav4-1.png"></div>
<div> <img src="http://imew.co.uk/wp-content/uploads/2017/03/cav4-1.png"></div>
</div>
</div>

<!--
Copyright (c) 2018 by Olgay Sezgin (https://codepen.io/olgaysezgin/pen/JBdrxE)
Fork of an original work by Martin Whitaker (https://codepen.io/sirnightowl/pen/JoJwrE)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-->

关于jquery - 猫头鹰轮播缩略图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47931108/

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