我试图创建一个多列自举轮播,但所有项目均以垂直显示,PFB是我的html代码:
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm"
crossorigin="anonymous">
<title>Hello, world!</title>
</head>
<body>
<h1>Hello, world!</h1>
<div id="myCarousel" class="carousel slide" data-ride="carousel" data-type="multi" data-interval="2000" style="border: 2px black; max-width: 400px; max-height: 400px;">
<div class="carousel-inner">
<div class="carousel-item active">
<div class="col-md-4 col-sm-6 col-xs-12">
<img class="d-block w-100" src="http://fresh2door.ie/wp-content/uploads/2017/06/Fresh2Door-Mango-Ready-To-Eat.jpg"
alt="First slide">
</div>
</div>
<div class="carousel-item">
<div class="col-md-4 col-sm-6 col-xs-12">
<img class="d-block w-100" src="http://sportsvape.net/wp-content/uploads/2014/09/Mango.jpg" alt="Second slide">
</div>
</div>
<div class="carousel-item">
<div class="col-md-4 col-sm-6 col-xs-12">
<img class="d-block w-100" src="https://jessicainthekitchen.com/wp-content/uploads/2017/05/Mango-Basil-Salsa-vegan-easy-6-453x680.jpg"
alt="Third slide">
</div>
</div>
<div class="carousel-item">
<div class="col-md-4 col-sm-6 col-xs-12">
<img class="d-block w-100" src="http://fresh2door.ie/wp-content/uploads/2017/06/Fresh2Door-Mango-Ready-To-Eat.jpg"
alt="First slide">
</div>
</div>
<div class="carousel-item">
<div class="col-md-4 col-sm-6 col-xs-12">
<img class="d-block w-100" src="http://sportsvape.net/wp-content/uploads/2014/09/Mango.jpg" alt="Second slide">
</div>
</div>
<div class="carousel-item">
<div class="col-md-4 col-sm-6 col-xs-12">
<img class="d-block w-100" src="https://jessicainthekitchen.com/wp-content/uploads/2017/05/Mango-Basil-Salsa-vegan-easy-6-453x680.jpg"
alt="Third slide">
</div>
</div>
<div class="carousel-item">
<div class="col-md-4 col-sm-6 col-xs-12">
<img class="d-block w-100" src="http://fresh2door.ie/wp-content/uploads/2017/06/Fresh2Door-Mango-Ready-To-Eat.jpg"
alt="First slide">
</div>
</div>
<div class="carousel-item">
<div class="col-md-4 col-sm-6 col-xs-12">
<img class="d-block w-100" src="http://sportsvape.net/wp-content/uploads/2014/09/Mango.jpg" alt="Second slide">
</div>
</div>
</div>
<a class="carousel-control-prev" href="#myCarousel" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#myCarousel" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN"
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q"
crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl"
crossorigin="anonymous"></script>
<script>
$('.carousel[data-type="multi"] .carousel-item').each(function () {
var next = $(this).next();
if (!next.length) {
next = $(this).siblings(':first');
}
next.children(':first-child').clone().appendTo($(this));
for (var i = 0; i < 1; i++) {
next = next.next();
if (!next.length) {
next = $(this).siblings(':first');
}
next.children(':first-child').clone().appendTo($(this));
}
});
</script>
</body>
</html>
答案 0 :(得分:1)
我想您正在尝试执行以下操作:
let storyboard = UIStoryboard(name: "Main", bundle: nil)
if let user_id = UserDefaults.standard.value(forKey: "uid")
{
let homeViewController = storyboard.instantiateViewController(withIdentifier: "HomeTabBarCtrlr") as! UITabBarController
let nav = UINavigationController(rootViewController: homeViewController)
self.window!.rootViewController = nav
}else{
如果您正在寻找其他东西,请更清楚地说明您的问题。
已编辑: 这正是您想要的:
HTML:
<div id="myCarousel" class="carousel slide" data-ride="carousel" data-type="multi" data-interval="2000" style="border: 2px black; max-width: 400px; max-height: 400px;">
<div class="carousel-inner">
<div class="carousel-item active">
<div class="row">
<div class="col-md-4 col-sm-6 col-xs-12">
<img class="d-block w-100" src="http://fresh2door.ie/wp-content/uploads/2017/06/Fresh2Door-Mango-Ready-To-Eat.jpg" alt="First slide">
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<img class="d-block w-100" src="http://sportsvape.net/wp-content/uploads/2014/09/Mango.jpg" alt="Second slide">
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<img class="d-block w-100" src="https://jessicainthekitchen.com/wp-content/uploads/2017/05/Mango-Basil-Salsa-vegan-easy-6-453x680.jpg"
alt="Third slide">
</div>
</div>
</div>
<div class="carousel-item">
<div class="row">
<div class="col-md-4 col-sm-6 col-xs-12">
<img class="d-block w-100" src="http://fresh2door.ie/wp-content/uploads/2017/06/Fresh2Door-Mango-Ready-To-Eat.jpg" alt="First slide">
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<img class="d-block w-100" src="http://sportsvape.net/wp-content/uploads/2014/09/Mango.jpg" alt="Second slide">
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<img class="d-block w-100" src="https://jessicainthekitchen.com/wp-content/uploads/2017/05/Mango-Basil-Salsa-vegan-easy-6-453x680.jpg"
alt="Third slide">
</div>
</div>
</div>
<div class="carousel-item">
<div class="row">
<div class="col-md-4 col-sm-6 col-xs-12">
<img class="d-block w-100" src="http://fresh2door.ie/wp-content/uploads/2017/06/Fresh2Door-Mango-Ready-To-Eat.jpg" alt="First slide">
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<img class="d-block w-100" src="http://sportsvape.net/wp-content/uploads/2014/09/Mango.jpg" alt="Second slide">
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<img class="d-block w-100" src="https://jessicainthekitchen.com/wp-content/uploads/2017/05/Mango-Basil-Salsa-vegan-easy-6-453x680.jpg"
alt="Third slide">
</div>
</div>
</div>
</div>
<a class="carousel-control-prev" href="#myCarousel" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#myCarousel" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
CSS:
<div class="container">
<h2>Our Partners</h2>
<section class="customer-logos slider">
<div class="slide"><img src="https://image.freepik.com/free-vector/luxury-letter-e-logo-design_1017-8903.jpg"></div>
<div class="slide"><img src="https://image.freepik.com/free-vector/3d-box-logo_1103-876.jpg"></div>
<div class="slide"><img src="https://image.freepik.com/free-vector/blue-tech-logo_1103-822.jpg"></div>
<div class="slide"><img src="https://image.freepik.com/free-vector/colors-curl-logo-template_23-2147536125.jpg"></div>
<div class="slide"><img src="https://image.freepik.com/free-vector/abstract-cross-logo_23-2147536124.jpg"></div>
<div class="slide"><img src="https://image.freepik.com/free-vector/football-logo-background_1195-244.jpg"></div>
<div class="slide"><img src="https://image.freepik.com/free-vector/background-of-spots-halftone_1035-3847.jpg"></div>
<div class="slide"><img src="https://image.freepik.com/free-vector/retro-label-on-rustic-background_82147503374.jpg"></div>
</section>
</div>
JS:
h2{
text-align:center;
padding: 20px;
}
/* Slider */
.slick-slide {
margin: 0px 20px;
}
.slick-slide img {
width: 100%;
}
.slick-slider
{
position: relative;
display: block;
box-sizing: border-box;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
-webkit-touch-callout: none;
-khtml-user-select: none;
-ms-touch-action: pan-y;
touch-action: pan-y;
-webkit-tap-highlight-color: transparent;
}
.slick-list
{
position: relative;
display: block;
overflow: hidden;
margin: 0;
padding: 0;
}
.slick-list:focus
{
outline: none;
}
.slick-list.dragging
{
cursor: pointer;
cursor: hand;
}
.slick-slider .slick-track,
.slick-slider .slick-list
{
-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;
top: 0;
left: 0;
display: block;
}
.slick-track:before,
.slick-track:after
{
display: table;
content: '';
}
.slick-track:after
{
clear: both;
}
.slick-loading .slick-track
{
visibility: hidden;
}
.slick-slide
{
display: none;
float: left;
height: 100%;
min-height: 1px;
}
[dir='rtl'] .slick-slide
{
float: right;
}
.slick-slide img
{
display: block;
}
.slick-slide.slick-loading img
{
display: none;
}
.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-arrow.slick-hidden {
display: none;
}
错误:
$(document).ready(function(){
$('.customer-logos').slick({
slidesToShow: 6,
slidesToScroll: 1,
autoplay: true,
autoplaySpeed: 1500,
arrows: false,
dots: false,
pauseOnHover: false,
responsive: [{
breakpoint: 768,
settings: {
slidesToShow: 4
}
}, {
breakpoint: 520,
settings: {
slidesToShow: 3
}
}]
});
});
(从您的代码中删除此脚本,这会在您的代码中引起奇怪的事情。)
答案 1 :(得分:0)
删除此脚本也为我修复了
{{-- <script src="https://cdn.jsdelivr.net/npm/jquery@3.4.1/dist/jquery.min.js"></script> --}}