我用它在滑块上显示图像。试试这个
<div class="col-md-12">
<div class="carousel carousel-showmanymoveone slide" id="carousel123">
<div class="carousel-inner">
<div class="item active">
<div class="col-xs-12 col-sm-6 col-md-3"> <img src="<?php echo plugin_dir_url( __FILE__ ) . \'img/download-1.jpg\'; ?>"></div>
</div>
<div class="item">
<div class="col-xs-12 col-sm-6 col-md-3"> <img src="<?php echo plugin_dir_url( __FILE__ ) . \'img/download-1.jpg\'; ?>"></div>
</div>
<div class="item">
<div class="col-xs-12 col-sm-6 col-md-3"> <img src="<?php echo plugin_dir_url( __FILE__ ) . \'img/download-1.jpg\'; ?>"></div>
</div>
<div class="item">
<div class="col-xs-12 col-sm-6 col-md-3"> <img src="<?php echo plugin_dir_url( __FILE__ ) . \'img/download-1.jpg\'; ?>"></div>
</div>
<div class="item">
<div class="col-xs-12 col-sm-6 col-md-3"> <img src="<?php echo plugin_dir_url( __FILE__ ) . \'img/download-1.jpg\'; ?>"></div>
</div>
<div class="item">
<div class="col-xs-12 col-sm-6 col-md-3"> <img src="<?php echo plugin_dir_url( __FILE__ ) . \'img/download-1.jpg\'; ?>"></div>
</div>
<div class="item">
<div class="col-xs-12 col-sm-6 col-md-3"> <img src="<?php echo plugin_dir_url( __FILE__ ) . \'img/download-1.jpg\'; ?>"></div>
</div>
<div class="item">
<div class="col-xs-12 col-sm-6 col-md-3"> <img src="<?php echo plugin_dir_url( __FILE__ ) . \'img/download-1.jpg\'; ?>"></div>
</div>
</div>
<a class="left carousel-control" href="#carousel123" data-slide="prev"><i class="glyphicon glyphicon-chevron-left"></i></a>
<a class="right carousel-control" href="#carousel123" data-slide="next"><i class="glyphicon glyphicon-chevron-right"></i></a>
</div>
</div>
</div>
脚本
(function(){
$(\'.carousel-showmanymoveone .item\').each(function(){
var itemToClone = $(this);
for (var i=1;i<4;i++) {
itemToClone = itemToClone.next();
// wrap around if at end of item collection
if (!itemToClone.length) {
itemToClone = $(this).siblings(\':first\');
}
// grab item, clone, add marker class, add to collection
itemToClone.children(\':first-child\').clone()
.addClass("cloneditem-"+(i))
.appendTo($(this));
}
});
}());
css
.carousel-showmanymoveone .carousel-control {
width: 4%;
background-image: none;
}
.carousel-showmanymoveone .carousel-control.left {
margin-left: 15px;
}
.carousel-showmanymoveone .carousel-control.right {
margin-right: 15px;
}
.carousel-showmanymoveone .cloneditem-1,
.carousel-showmanymoveone .cloneditem-2,
.carousel-showmanymoveone .cloneditem-3 {
display: none;
}
@media all and (min-width: 768px) {
.carousel-showmanymoveone .carousel-inner > .active.left,
.carousel-showmanymoveone .carousel-inner > .prev {
left: -50%;
}
.carousel-showmanymoveone .carousel-inner > .active.right,
.carousel-showmanymoveone .carousel-inner > .next {
left: 50%;
}
.carousel-showmanymoveone .carousel-inner > .left,
.carousel-showmanymoveone .carousel-inner > .prev.right,
.carousel-showmanymoveone .carousel-inner > .active {
left: 0;
}
.carousel-showmanymoveone .carousel-inner .cloneditem-1 {
display: block;
}
}
@media all and (min-width: 768px) and (transform-3d), all and (min-width: 768px) and (-webkit-transform-3d) {
.carousel-showmanymoveone .carousel-inner > .item.active.right,
.carousel-showmanymoveone .carousel-inner > .item.next {
-webkit-transform: translate3d(50%, 0, 0);
transform: translate3d(50%, 0, 0);
left: 0;
}
.carousel-showmanymoveone .carousel-inner > .item.active.left,
.carousel-showmanymoveone .carousel-inner > .item.prev {
-webkit-transform: translate3d(-50%, 0, 0);
transform: translate3d(-50%, 0, 0);
left: 0;
}
.carousel-showmanymoveone .carousel-inner > .item.left,
.carousel-showmanymoveone .carousel-inner > .item.prev.right,
.carousel-showmanymoveone .carousel-inner > .item.active {
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
left: 0;
}
}
@media all and (min-width: 992px) {
.carousel-showmanymoveone .carousel-inner > .active.left,
.carousel-showmanymoveone .carousel-inner > .prev {
left: -25%;
}
.carousel-showmanymoveone .carousel-inner > .active.right,
.carousel-showmanymoveone .carousel-inner > .next {
left: 25%;
}
.carousel-showmanymoveone .carousel-inner > .left,
.carousel-showmanymoveone .carousel-inner > .prev.right,
.carousel-showmanymoveone .carousel-inner > .active {
left: 0;
}
.carousel-showmanymoveone .carousel-inner .cloneditem-2,
.carousel-showmanymoveone .carousel-inner .cloneditem-3 {
display: block;
}
}