对于“ Slick”轮播中的类似问题,我已经浏览了先前的答案,并尝试了所有建议,但仍然无法正常工作。
第一个问题是轮播对我们来说是广泛的。我尝试应用最大宽度等,但是第二个问题是图像仍然无法响应。
我直接从Slick网站上获取了代码并按要求进行了应用,但是遇到了这个问题,现在尝试了Codepen的代码(当然可以在那儿工作),但是在应用于我的网站时,其效果与上面提到的完全相同托管在电子商务平台Bluepark中。
这是我应用于演示Bluepark网站的代码: http://bp95.betapark.co.uk
这是我从中获得此代码的位置: https://codepen.io/flannerydesigns/pen/pbzOgg
<!-- START SLICK SLIDER -->
<div class="slider-wrapper">
<div class="slider responsive lazy">
<div>
<div class="image"><img class="slick-slider-img" alt="Alt" src="https://images.unsplash.com/photo-1464082354059-27db6ce50048?format=auto&auto=compress&dpr=1&crop=entropy&fit=crop&w=1271&h=847&q=80" /></div>
</div>
<div>
<div class="image"><img class="slick-slider-img" alt="Alt" src="https://images.unsplash.com/photo-1445023835378-9fa9a2089f0c?format=auto&auto=compress&dpr=1&crop=entropy&fit=crop&w=1271&h=953&q=80" /></div>
</div>
<div>
<div class="image"><img class="slick-slider-img" alt="Alt" src="https://images.unsplash.com/photo-1441040744088-a70b8213d4d4?format=auto&auto=compress&dpr=1&crop=entropy&fit=crop&w=1271&h=847&q=80" /></div>
</div>
<div>
<div class="image"><img class="slick-slider-img" alt="Alt" src="https://images.unsplash.com/photo-1463608666382-cbb244a7bea2?format=auto&auto=compress&dpr=1&crop=entropy&fit=crop&w=1271&h=1769&q=80" /></div>
</div>
</div>
<div class="slider-progress">
<div class="progress"></div>
</div>
</div>
<!-- END SLICK SLIDER -->
/* Slider */
.slider-wrapper{
position: relative;
width: 100%;
height: 600px;
overflow: hidden;
}
.slick-slider {
position: relative;
display: block;
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
-ms-touch-action: none;
touch-action: none;
-webkit-tap-highlight-color: transparent;
}
.slick-list {
position: relative;
overflow: hidden;
display: block;
margin: 0;
padding: 0;
}
.slick-list:focus {
outline: none;
}
.slick-list.dragging {
cursor: pointer;
cursor: hand;
}
.slick-slider .slick-list,
.slick-track,
.slick-slide,
.slick-slide img {
-webkit-transform: translate3d(0, 0, 0);
-moz-transform: translate3d(0, 0, 0);
-ms-transform: translate3d(0, 0, 0);
-o-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
.slick-track {
position: relative;
left: 0;
top: 0;
display: block;
zoom: 1;
}
.slick-track:before,
.slick-track:after {
content: "";
display: table;
}
.slick-track:after {
clear: both;
}
.slick-loading .slick-track {
visibility: hidden;
}
.slick-slide {
float: left;
height: 100%;
min-height: 1px;
display: none;
}
.slick-slide img {
display: block;
max-width: 100%;
}
.slick-slide.dragging img {
pointer-events: none;
}
.slick-initialized .slick-slide {
display: block;
}
.slick-loading .slick-slide {
visibility: hidden;
}
.slick-vertical .slick-slide {
display: block;
height: auto;
border: 1px solid transparent;
}
.slick-slide > .slick-slider-img {
position: relative;
display: block;
width: 100%;
}
.slick-slide .image {
/*height: 180px;*/
}
.slick-slide img {
display: block;
width: 100%;
}
.slick-slide img.slick-loading {
display: none;
}
.slick-prev{
background: #DDD;
border: none;
border-radius: none;
position: absolute;
top: 20%;
transform: translateY(-20%);
left: 0;
padding: 0.25em 0.5em;
box-shadow: 2px 2px 4px rgba(0,0,0,0.25);
z-index: 400;
}
.slick-next{
background: #DDD;
border: none;
border-radius: none;
position: absolute;
top: 20%;
transform: translateY(-20%);
right: 0;
padding: 0.25em 0.5em;
box-shadow: 2px 2px 4px rgba(0,0,0,0.25);
z-index: 400;
}
/* progress bar */
.slider-progress {
width: 100%;
height: 10px;
background: rgba(255,255,255,0.5);
position: absolute;
bottom: 0;
}
.slider-progress .progress {
width: 0%;
height: 10px;
background: #e74c3c;
}
$(document).ready(function() {
var time = 2;
var $bar,
$slick,
isPause,
tick,
percentTime;
$slick = $('.slider');
$slick.slick({
arrows: true,
speed: 1200,
adaptiveHeight: false
});
$bar = $('.slider-progress .progress');
function startProgressbar() {
resetProgressbar();
percentTime = 0;
isPause = false;
tick = setInterval(interval, 30);
}
function interval() {
if (isPause === false) {
percentTime += 1 / (time + 0.1);
$bar.css({
width: percentTime + "%"
});
if (percentTime >= 100) {
$slick.slick('slickNext');
startProgressbar();
}
}
}
function resetProgressbar() {
$bar.css({
width: 0 + '%'
});
clearTimeout(tick);
}
startProgressbar();
$('.slick-next, .slick-prev').click(function() {
startProgressbar();
});
});
任何帮助或建议都将不胜感激,因为我对此一无所知-预先感谢。