I'm having trouble with containing responsive images inside a carousel slide and currently the carousel is not able to slide to either the next or previous one. Any help is appreciated, thanks.
<h2 class="caption-2"> UI Snippets</h2>
<h2 class="description-2"> .</h2>
<div id="ui-carousel" class="carousel slide" data-ride="false">
<div class="carousel-inner" role="listbox" style="max-width:100%; max-height:630px !important;">
<div class="carousel-item active container-fluid">
<img class="design-1" src="UI-Designs/Day&Night.png" alt="Mock-Up">
</div>
<div class="carousel-item container-fluid">
<div class="row">
<div class="col-lg-4 col-md-6">
<img class="design-2" src="UI-Designs/Hiking.jpg" alt="Mock-Up">
</div>
<div class="col-lg-4 col-md-6">
<img class="design-2" src="UI-Designs/Homescreen.jpg" alt="Mock-Up">
</div>
<div class="col-lg-4 col-md-6">
<img class="design-2" src="UI-Designs/Cycling.jpg" alt="Mock-Up">
</div>
</div>
</div>
<div class="carousel-item container-fluid">
<video width=100% controls>
<source src="Echo.mp4" type="video/mp4">
</video>
</div>
</div>
<a class="carousel-control-prev" href="#ui-carousel" role="button" data-slide="prev">
<span class="carousel-control-prev-icon"></span>
</a>
<a class="carousel-control-next" href="#ui-carousel" role="button" data-slide="next">
<span class="carousel-control-next-icon"></span>
</a>
</div>
</div>```
<div class="container">
<h2>Carousel Example</h2>
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item active">
<img src="la.jpg" alt="Los Angeles" style="width:100%;">
</div>
<div class="item">
<img src="chicago.jpg" alt="Chicago" style="width:100%;">
</div>
<div class="item">
<img src="ny.jpg" alt="New york" style="width:100%;">
</div>
</div>
<!-- Left and right controls -->
<a class="left carousel-control" href="#myCarousel" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
Related
I added 2 bootstrap 5 carousels on the same page, added unique ID to each of them, but sadly the second carousel mixes photos with the first carousel. It takes 2 photos from the previous slide. Adding unique ID's to each carousel didn't change the situation.
Is there a solution to this?
I checked also this post but it didn't help:
How to place two bootstrap carousels in the same page?
<!-- Bootstrap carousel 1 -->
<div class="container text-center my-3 mb-5">
<div class="row mx-auto my-auto justify-content-between">
<div id="Carousel-1" class="carousel slide" data-bs-ride="carousel">
<div class="carousel-inner" role="listbox">
<div class="carousel-item active">
<div class="col-md-4">
<div class="card">
<div class="card-img">
<img src="./images/person1.jpg" class="img-fluid">
</div>
<div class="card-img-overlay"><strong>John Smith</strong>
<p class="mt-0 me-2" style="font-size: 13px;">Administration</p>
</div>
</div>
</div>
</div>
<div class="carousel-item">
<div class="col-md-4">
<div class="card">
<div class="card-img">
<img src="./images/person2.jpg" class="img-fluid">
</div>
<div class="card-img-overlay"><strong>Sarah Smith</strong>
<p class="mt-0 me-2" style="font-size: 13px;">Finance</p>
</div>
</div>
</div>
</div>
<div class="carousel-item">
<div class="col-md-4">
<div class="card">
<div class="card-img">
<img src="./images/person3.jpg" class="img-fluid">
</div>
<div class="card-img-overlay"><strong>Roger Kensinghton</strong>
<p class="mt-0 me-2" style="font-size: 13px;">Security</p>
</div>
</div>
</div>
</div>
<div class="carousel-item">
<div class="col-md-4">
<div class="card">
<div class="card-img">
<img src="./images/person4.jpg" class="img-fluid">
</div>
<div class="card-img-overlay"><strong>Kelly Parker</strong>
<p class="mt-0 me-2" style="font-size: 13px;">Design</p>
</div>
</div>
</div>
</div>
</div>
<a class="carousel-control-prev bg-transparent w-aut" href="#Carousel-1" role="button" data-bs-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
</a>
<a class="carousel-control-next bg-transparent w-aut" href="#Carousel-1" role="button" data-bs-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
</a>
</div>
</div>
</div>
<!-- Bootstrap carousel 2 -->
<div class="container text-center my-3 mb-5 carousel2">
<div class="row mx-auto my-auto justify-content-between">
<div id="Carousel-2" class="carousel slide" data-bs-ride="carousel">
<div class="carousel-inner" role="listbox">
<div class="carousel-item active">
<div class="col-md-4">
<div class="card">
<div class="card-img">
<img src="./images/woman1.jpg" class="img-fluid">
</div>
<div class="card-img-bottom"><strong>Jane Dow</strong>
<p class="mt-0 me-2" style="font-size: 13px;">CEO AXA Group</p>
</div>
</div>
</div>
</div>
<div class="carousel-item">
<div class="col-md-4">
<div class="card">
<div class="card-img">
<img src="./images/man1.jpg" class="img-fluid">
</div>
<div class="card-img-bottom"><strong>Dave Johnson</strong>
<p class="mt-0 me-2" style="font-size: 13px;">Marketing Manager Johnson's & Co</p>
</div>
</div>
</div>
</div>
<div class="carousel-item">
<div class="col-md-4">
<div class="card">
<div class="card-img">
<img src="./images/man2.jpg" class="img-fluid">
</div>
<div class="card-img-bottom"><strong>Roger Smith</strong>
<p class="mt-0 me-2" style="font-size: 13px;">CEO Hi-Tech Intl.</p>
</div>
</div>
</div>
</div>
<div class="carousel-item">
<div class="col-md-4">
<div class="card">
<div class="card-img">
<img src="./images/woman2.jpg" class="img-fluid">
</div>
<div class="card-img-bottom"><strong>Diana Russel</strong>
<p class="mt-0 me-2" style="font-size: 13px;">Manager Creativity Hub</p>
</div>
</div>
</div>
</div>
</div>
<a class="carousel-control-prev bg-transparent w-aut" href="#Carousel-2" role="button" data-bs-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
</a>
<a class="carousel-control-next bg-transparent w-aut" href="#Carousel-2" role="button" data-bs-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
</a>
</div>
</div>
</div>
let items = document.querySelectorAll('.carousel .carousel-item')
items.forEach((el) => {
const minPerSlide = 3
let next = el.nextElementSibling
for (var i=1; i<minPerSlide; i++) {
if (!next) {
// wrap carousel by using first child
next = items[0]
}
let cloneChild = next.cloneNode(true)
el.appendChild(cloneChild.children[0])
next = next.nextElementSibling
}
})
because you use .carousal selector and class is present in both carousals use ids instead of class #Carousel-1 or #Carousel-2
let items = document.querySelectorAll('#Carousel-1 .carousel-item')
I have a two image carousel where each image is a different size. I am trying to make all of them vertically align in the middle in order to look much more cleaner.
I tried: margin, display: block, vertical-align: middle. none make the images in the carousel center.
<div class="container">
<div class="col-md-12 text-align-center">
<h2 class="bold_font">FEATURED PARTNERS</h2><br>
</div>
<div class="row">
<div class="col-xs-4">
<a href="../cards/list-partners.php">
<div class="hvrbox">
<img src="img/_stock_mwc_partners.jpg" class="img-responsive hvrbox-layer_bottom">
<div class=" hvrbox-mwc-orange hvrbox-layer_top hvrbox-layer_slideright">
<div class="hvrbox-text">
<h2>BROWSE<br>PARTNERS</h2>
</div>
</div>
</div>
</a>
</div>
<div class="col-xs-8">
<div id="imageCarousel" class="carousel slide" data-interval="2000" data-ride="carousel" data-pause="hover" data-wrap="true">
<div class="carousel-inner">
<div class="item active">
<div class="row">
<div class="col-md-6 img-center-vertical">
<img src="img/uploads/merchant-12-GLOBAL ELITE DENTAL CLINIC.jpg" class="img-responsive">
</div>
<div class="col-md-6 img-center-vertical">
<img src="img/uploads/merchant-17-Mimmo Logo.jpg" class="img-responsive">
</div>
</div>
</div>
<div class="item">
<div class="row">
<div class="col-md-6 img-center-vertical">
<img src="img/uploads/merchant-18-LOGO CORE.png" class="img-responsive">
</div>
<div class="col-md-6 img-center-vertical">
<img src="img/uploads/merchant-19-docnic_newlogo-3.png" class="img-responsive">
</div>
</div>
</div>
</div>
<a href="#imageCarousel" class="carousel-control left" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
</a>
<a href="#imageCarousel" class="carousel-control right" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
</a>
</div>
</div>
</div>
</div>
We can achieve this using display table & display table cell.
.item row{
display:table;
}
.img-center-vertical{
display:table-cell;
vertical-align:middle;
height:300px;
float: inherit;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" >
<div class="container">
<div class="col-md-12 text-align-center">
<h2 class="bold_font">FEATURED PARTNERS</h2><br>
</div>
<div class="row">
<div class="col-xs-4">
<a href="../cards/list-partners.php">
<div class="hvrbox">
<img src="http://placehold.it/300/f44336/000000" class="img-responsive hvrbox-layer_bottom">
<div class=" hvrbox-mwc-orange hvrbox-layer_top hvrbox-layer_slideright">
<div class="hvrbox-text">
<h2>BROWSE<br>PARTNERS</h2>
</div>
</div>
</div>
</a>
</div>
<div class="col-xs-8">
<div id="imageCarousel" class="carousel slide" data-interval="false" data-ride="carousel" data-pause="hover" data-wrap="true">
<div class="carousel-inner">
<div class="item active">
<div class="row">
<div class="col-md-6 img-center-vertical">
<img src="http://placehold.it/300/f44336/000000" class="img-responsive">
</div>
<div class="col-md-6 img-center-vertical">
<img src="http://placehold.it/200/f44336/000000" class="img-responsive">
</div>
</div>
</div>
<div class="item">
<div class="row">
<div class="col-md-6 img-center-vertical">
<img src="http://placehold.it/300/f44336/000000" class="img-responsive">
</div>
<div class="col-md-6 img-center-vertical">
<img src="http://placehold.it/200/f44336/000000" class="img-responsive">
</div>
</div>
</div>
</div>
<a href="#imageCarousel" class="carousel-control left" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
</a>
<a href="#imageCarousel" class="carousel-control right" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
</a>
</div>
</div>
</div>
</div>
Check out the codepen
.img-center-vertical {
display: inline-block;
text-align: center;
justify-content: center;
}
Try this
.img-center-vertical {
display: flex;
align-items: center;
justify-content: center;
}
Attached image contains the html code part where I need to add a left right scroll able button. However i cannot see the complete images one after another. Currently it shows an animated view. In addition to the same I need next prev button also.
<section class="sponser-area section-padding" id="sponsors">
<div id="sponsors" class="carousel slide carousel-fade" data-ride="carousel">
<div class="container text-center">
<div class="row">
<div class="page-title">
<h2>Insurance Partners</h2>
<p>Consectetuer adipiscing elit, sed diam nonummy</p>
</div>
<div class="sponser-items">
<div class="sponser-item">
<img src="images/sponser/01_sponser.jpg" alt="Helth plus">
</div>
<div class="sponser-item">
<img src="images/sponser/02_sponser.jpg" alt="Helth plus">
</div>
<div class="sponser-item">
<img src="images/sponser/03_sponser.jpg" alt="Helth plus">
</div>
<div class="sponser-item">
<img src="images/sponser/04_sponser.jpg" alt="Helth plus">
</div>
<div class="sponser-item">
<img src="images/sponser/15_sponser.jpg" alt="Helth plus">
</div>
<div class="sponser-item">
<img src="images/sponser/16_sponser.jpg" alt="Helth plus">
</div>
<div class="sponser-item">
<img src="images/sponser/17_sponser.jpg" alt="Helth plus">
<div class="sponser-item">
<img src="images/sponser/23_sponser.jpg" alt="Helth plus">
</div>
</div>
</div>
<a class="left slide-control" href="#home_slider" role="button" data-slide="prev">
<span class="glyphicon glyphicon-triangle-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right slide-control" href="#home_slider" role="button" data-slide="next">
<span class="glyphicon glyphicon-triangle-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
</section>
I have used bootstrap carousel to show 3 items on a row, and it works on a good way. But I want to show only one item for the small devices(mobiles or tablets). Can anyone help me please?
Here is the code I have used
<section id="services" class="service">
<div class="container">
<div class="row">
<div class="col-lg-12 text-center">
<h2 class="section-heading" style="font-family:daniel; font-weight:bolder; font-size:40px; color:#F9121A;">WorkShops & Tracks</h2>
<hr class="primary">
</div>
</div>
</div><br>
<div id="myCarousel" class="carousel slide" data-ride="carousel" >
<div class="container">
<div class="row">
<!-- Indicators -->
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item active">
<div class="col-lg-4 col-md-4 text-center">
<div class="service-box">
<img src="img/img.jpg" class="text-primary sr-icons" width="200px" height="150px">
<h3 style="color:#F9121A;"></h3>
<p class="text-muted" >
</p>
Show Details
</div>
</div>
<div class="col-lg-4 col-md-4 text-center">
<div class="service-box">
<img src="img.jpg" class="text-primary sr-icons" width="200px" height="150px">
<h3 style="color:#F9121A;"></h3>
<p class="text-muted" >
</p>
Show Details
</div>
</div>
<div class="col-lg-4 col-md-4 text-center">
<div class="service-box">
<img src="img.jpg" class="text-primary sr-icons" width="200px" height="150px"><br><br>
<h3 style="color:#F9121A;"></h3>
<p class="text-muted" >
</p>
Show Details
</div>
</div>
</div>
<div class="item">
<div class="col-lg-4 col-md-4 text-center">
<div class="service-box">
<img src="img.jpg" class="text-primary sr-icons" width="200px" height="150px">
<h3 style="color:#F9121A;"></h3>
<p class="text-muted" >
</p>
Show Details
</div>
</div>
<div class="col-lg-4 col-md-4 text-center">
<div class="service-box">
<img src="img.jpg" class="text-primary sr-icons" width="200px" height="150px">
<h3 style="color:#F9121A;"></h3>
<p class="text-muted" >
</p>
Show Details
</div>
</div>
<div class="col-lg-4 col-md-4 text-center">
<div class="service-box">
<img src="img.jpg" class="text-primary sr-icons" width="200px" height="150px">
<h3 style="color:#F9121A;"></h3>
<p class="text-muted" >
</p>
Show Details
</div>
</div>
</div>
</div>
<!-- Left and right controls -->
<a class="left carousel-control" href="#myCarousel" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
</div>
</section>
I would use a media query with javascript.
https://www.sitepoint.com/javascript-media-queries/
hi so this is the code
<div id='mai'>
<div class="jumbotron">
<div class="container">
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
<li data-target="#carousel-example-generic" data-slide-to="1"></li>
<li data-target="#carousel-example-generic" data-slide-to="2"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="img/2.jpg" alt="">
<div class="carousel-caption">
...
</div>
</div>
<div class="item">
<img src="img/3.jpg" alt="">
<div class="carousel-caption">
...
</div>
</div>
...
</div>
<!-- Controls -->
<a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">pre</span>
</a>
<a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">nx</span>
</a>
</div>
</div>
</div>
</div>
<h3>Example heading <span class="label label-default">New</span></h3>
<div class="row">
<div class="col-sm-6 col-md-4">
<div class="thumbnail">
<img src="img/4.jpg" alt="..">
<div class="caption">
<h3>برنده لوح تقدیر</h3>
<p>...</p>
<p>Button Button</p>
</div>
</div>
</div>
<div class="col-sm-6 col-md-4">
<div class="thumbnail">
<img data-src="holder.js/300x300" alt="...">
<div class="caption">
<h3>Thumbnail label</h3>
<p>...</p>
<p>Button Button</p>
</div>
</div>
</div>
<div class="col-sm-6 col-md-4">
<div class="thumbnail">
<img data-src="holder.js/300x300" alt="...">
<div class="caption">
<h3>Thumbnail label</h3>
<p>...</p>
<p>Button Button</p>
</div>
</div>
</div>
</div>
i tried to change the height and width with class mai , but it wont change my carousel div height and it will broke my thumbnails and brings them upward towards the main carousel ...
what should i do ????