HTML5 VIdeo Controls visibility / z-index - html

Hello I have a Carousel in bootstrap with a video in it
The main problem I can't fix is that video controls cannot be clicked because of the carousel indicators.
I tried to add some margin and padding to them and it worked for the begging and the end of the video (where the two coincide, but then in the middle of the seeking bar I can't click without any reason). If I didn't explain me please let me know.
I couldn't add any snippet but you can see what I am trying to explain on my site: Here
HTML:
<div id="carousel-home" class="carousel slide carousel-fade" data-ride="carousel" data-interval="false">
<ol class="carousel-indicators">
<li data-target="#carousel-home" data-slide-to="0" class="active"></li>
<li data-target="#carousel-home" data-slide-to="1" id="slide_1"></li>
<li data-target="#carousel-home" data-slide-to="2" id="slide_2"></li>
<li data-target="#carousel-home" data-slide-to="3" id="slide_3"></li>
</ol>
<div class="carousel-inner" role="listbox">
<div class="carousel-item active">
<video id="myvideo" class="crop" poster="imgs/video_thumb.jpg" preload="auto" playsinline controls>
<source src="vid/video_2019.mp4" type="video/mp4" onclick="this.play();">
</video>
</div>
<div class="carousel-item">
<img class="d-block w-100 mx-auto" src="imgs/slider/1.png" alt="First slide">
<div class="carousel-caption">
<h2 class="title" style="text-shadow: 1px 1px black">First</h2>
</div>
</div>
<div class="carousel-item">
<img class="d-block w-100 mx-auto" src="imgs/slider/2.png" alt="Second slide">
<div class="carousel-caption">
<h2 class="title" style="text-shadow: 1px 1px black">Second</h2>
</div>
</div>
<div class="carousel-item">
<img class="d-block w-100 mx-auto" src="imgs/slider/3.png" alt="Third slide">
<div class="carousel-caption">
<h2 class="title" style="text-shadow: 1px 1px black">Third</h2>
</div>
</div>
</div>
<a class="carousel-control-prev" href="#carousel-home" role="button" data-slide="prev" id="carousel_l">
<i class="fa fa-chevron-left"></i>
<span class="sr-only">Back</span>
</a>
<a class="carousel-control-next" href="#carousel-home" role="button" data-slide="next" id="carousel_r">
<i class="fa fa-chevron-right"></i>
<span class="sr-only">Next</span>
</a>
</div>
CSS:
.carousel-indicators li {
margin-bottom: 2rem;
padding-bottom: 1rem;
padding-top: 1rem;
border-radius: 100%;
}
.carousel-item img {
object-fit: cover
}
.carousel-item {
overflow:hidden;
}
JQuery:
$(window).ready(function() {
$('#carousel_l').on("click", function() {
$('#myvideo').get(0).pause();
});
$('#carousel_r').on("click", function () {
$('#myvideo').get(0).pause();
});
$('#slide_1').on("click", function () {
$('#myvideo').get(0).pause();
});
$('#slide_2').on("click", function () {
$('#myvideo').get(0).pause();
});
$('#slide_3').on("click", function () {
$('#myvideo').get(0).pause();
});
});

You can use
.carousel-indicators {
pointer-events: none;
}
.carousel-indicators > li {
pointer-events: auto;
}
to remove the interactivity of the carousel indicators.

Related

Slider not fitting span of window css issue?

Hi everyone nice to be here on stackoverflow, I'm just having a bit of trouble fitting the slider to the span of the window happens in every browser any ideas would be very greatful. Thank you in advance. I have added the CSS and HTML code below this comment.
Hi everyone nice to be here on stackoverflow, I'm just having a bit of trouble fitting the slider to the span of the window happens in every browser any ideas would be very greatful. Thank you in advance. I have added the CSS and HTML code below this comment.
Snapshot of site im working on
/*-----Slider-----*/
#slider{
width: 100%;
margin: auto;
font-family: Chakra Petch;
}
.carousel-caption{
top: 50%;
transform: translateY(-50%);
bottom: initial !important;
}
.h1-0{
color: black !important;
font-size: 40px;
font-weight: bold;
background: #fff !important;
opacity: 0.8;
}
.h1-1{
color: black !important;
font-size: 40px;
font-weight: bold;
background: #fff !important;
opacity: 0.8;
}
.h1-2{
color: black !important;
font-size: 40px;
font-weight: bold;
background: #fff !important;
opacity: 0.8;
}
.h1-3{
color: black !important;
font-size: 40px;
font-weight: bold;
background: #fff !important;
opacity: 0.8;
}
<!-- Slider -->
<div id="slider" data-aos="fade-up" data-aos-duration="2000" data-aos-delay="1300">
<div id="headerSlider" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#headerSlider" data-slide-to="0" class="active"></li>
<li data-target="#headerSlider" data-slide-to="1"></li>
<li data-target="#headerSlider" data-slide-to="2"></li>
<li data-target="#headerSlider" data-slide-to="3"></li>
<li data-target="#headerSlider" data-slide-to="4"></li>
</ol>
<div class="carousel-inner">
<div class="carousel-item active">
<img src="img/welcome-slider-image.jpg" class="d-block img-fluid" alt="Welcome Image">
</div>
<div class="carousel-item">
<img src="img/webdesign-image.jpg" class="d-block img-fluid" alt="Website Design Image">
<div class="carousel-caption">
<h1 class="h1-0">Web Site Design</h1>
</div>
</div>
<div class="carousel-item">
<img src="img/seo-slider-image.jpeg" class="d-block img-fluid" alt="SEO Image">
<div class="carousel-caption">
<h1 class="h1-1">Search Engine Optimization<br></h1>
</div>
</div>
<div class="carousel-item">
<img src="img/software-development-slider-image.png" class="d-block img-fluid" alt="App Development Image">
<div class="carousel-caption">
<h1 class="h1-2">App & Software Development<br></h1>
</div>
</div>
<div class="carousel-item">
<img src="img/cyber-security.jpg" class="d-block img-fluid" alt="Software Development Image">
<div class="carousel-caption">
<h1 class="h1-3">Cyber Security<br></h1>
</div>
</div>
</div>
<a class="carousel-control-prev" href="#headerSlider" 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="#headerSlider" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>

Use MultiItem Bootstrap Carousel SlideShow beside a Simple SlideShow

i'm creating a website and must show product in sliders.i use a simple Carousel slide show and a multi Item Slide Show in one page.multi Item Slide Show had a css class.
when i add this class refrence to page simple Carousel slide show Disrupts and multi Item Slide Show not work correctly.
when i delete multi Item Slide Show css refrence simple Carousel slide work correctly.
i used multi Item Slide Show which doesnt need to css file and work perefect,but this multi Item Slide Show doesnt support responsive principles and i don't want to use this kind of multi Item Slide Show.
i gusse my pure bootstratp css Carousel code conflicts with multi Item Slide Show css file, How can i solve this problem.
UPDATE
I Attach snippe
d code below:
this is my head tag in _SharedView Page
<link href="~/bootstrap-4.3.1-dist/css/bootstrap.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="~/bootstrap-4.3.1-dist/js/bootstrap.js"></script>
and my simple Carousel Slide Show in index.cshtml View:
<div id="demo" class="carousel slide" data-ride="carousel">
<ul class="carousel-indicators">
<li data-target="#demo" data-slide-to="0" class="active"></li>
<li data-target="#demo" data-slide-to="1"></li>
<li data-target="#demo" data-slide-to="2"></li>
</ul>
<div class="carousel-inner">
<div class="carousel-item active">
<img src="https://www.w3schools.com/bootstrap4/la.jpg" alt="Los Angeles" width="1100" height="500">
<div class="carousel-caption">
<h3>Los Angeles</h3>
<p>We had such a great time in LA!</p>
</div>
</div>
<div class="carousel-item">
<img src="https://www.w3schools.com/bootstrap4/chicago.jpg" alt="Chicago" width="1100" height="500">
<div class="carousel-caption">
<h3>Chicago</h3>
<p>Thank you, Chicago!</p>
</div>
</div>
<div class="carousel-item">
<img src="https://www.w3schools.com/bootstrap4/ny.jpg" alt="New York" width="1100" height="500">
<div class="carousel-caption">
<h3>New York</h3>
<p>We love the Big Apple!</p>
</div>
</div>
</div>
<a class="carousel-control-prev" href="#demo" data-slide="prev">
<span class="carousel-control-prev-icon"></span>
</a>
<a class="carousel-control-next" href="#demo" data-slide="next">
<span class="carousel-control-next-icon"></span>
</a> </div>
and multi Item Slide Show in index.cshtml View:
<div class="container">
<div class="carousel-wrapper">
<div id="carouselExample" class="carousel slide" data-ride="carousel" data-interval="9000">
<div class="carousel-inner w-100 row no-gutters" role="listbox">
<div class="carousel-item col-md-4 active">
<img class="img-fluid mx-auto d-block" src="https://placehold.it/600x300/888/fff?text=1" alt="slide 1">
</div>
<div class="carousel-item col-md-4">
<img class="img-fluid mx-auto d-block" src="https://placehold.it/600x300/DD2222?text=2" alt="slide 2">
</div>
<div class="carousel-item col-md-4">
<img class="img-fluid mx-auto d-block" src="https://placehold.it/600x300/22DD22?text=3" alt="slide 3">
</div>
<div class="carousel-item col-md-4">
<img class="img-fluid mx-auto d-block" src="https://placehold.it/600x300/FFCC11?text=4" alt="slide 4">
</div>
<div class="carousel-item col-md-4">
<img class="img-fluid mx-auto d-block" src="https://placehold.it/600x300/0099FF?text=5" alt="slide 5">
</div>
<div class="carousel-item col-md-4">
<img class="img-fluid mx-auto d-block" src="https://placehold.it/600x300?text=6" alt="slide 6">
</div>
<div class="carousel-item col-md-4">
<img class="img-fluid mx-auto d-block" src="https://placehold.it/600x300/4455DD?text=7" alt="slide 7">
</div>
<div class="carousel-item col-md-4">
<img class="img-fluid mx-auto d-block" src="https://placehold.it/600x300?text=8" alt="slide 8">
</div>
</div>
<a class="carousel-control-prev text-dark my-auto" href="#carouselExample" role="button" data-slide="prev">
<i class="fa fa-chevron-left fa-lg"></i>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next text-dark" href="#carouselExample" role="button" data-slide="next">
<i class="fa fa-chevron-right fa-lg"></i>
<span class="sr-only">Next</span>
</a>
</div>
</div>
</div>
I also Attach this css code to my project:
#media (min-width: 768px) {
.carousel-wrapper {
overflow-x:hidden;
}
/* show 3 items */
.carousel-inner .active,
.carousel-inner .active + .carousel-item,
.carousel-inner .active + .carousel-item + .carousel-item {
display: block;
}
.carousel-inner .carousel-item.active:not(.carousel-item-right):not(.carousel-item-left),
.carousel-inner .carousel-item.active:not(.carousel-item-right):not(.carousel-item-left) + .carousel-item,
.carousel-inner .carousel-item.active:not(.carousel-item-right):not(.carousel-item-left) + .carousel-item + .carousel-item {
transition: none;
}
.carousel-inner .carousel-item-next,
.carousel-inner .carousel-item-prev {
position: relative;
transform: translate3d(0, 0, 0);
}
.carousel-inner .active.carousel-item + .carousel-item + .carousel-item + .carousel-item {
position: absolute;
top: 0;
right: -33%;
z-index: -1;
display: block;
visibility: visible;
}
/* left or forward direction */
.active.carousel-item-left + .carousel-item-next.carousel-item-left,
.carousel-item-next.carousel-item-left + .carousel-item,
.carousel-item-next.carousel-item-left + .carousel-item + .carousel-item,
.carousel-item-next.carousel-item-left + .carousel-item + .carousel-item + .carousel-item {
position: relative;
transform: translate3d(-100%, 0, 0);
visibility: visible;
}
/* farthest right hidden item must be abso position for animations */
.carousel-inner .carousel-item-prev.carousel-item-right {
position: absolute;
top: 0;
left: 0;
z-index: -1;
display: block;
visibility: visible;
}
/* right or prev direction */
.active.carousel-item-right + .carousel-item-prev.carousel-item-right,
.carousel-item-prev.carousel-item-right + .carousel-item,
.carousel-item-prev.carousel-item-right + .carousel-item + .carousel-item,
.carousel-item-prev.carousel-item-right + .carousel-item + .carousel-item + .carousel-item {
position: relative;
transform: translate3d(100%, 0, 0);
visibility: visible;
display: block;
visibility: visible;
}
}
and this java script:
$('.carousel').on('slide.bs.carousel', function (e) {
var $e = $(e.relatedTarget);
var $t = $(this);
var $inner = $t.find('.carousel-inner');
var idx = $e.index();
var itemsPerSlide = 3;
var totalItems = $t.find('.carousel-item').length;
if (idx >= totalItems-(itemsPerSlide-1)) {
var it = itemsPerSlide - (totalItems - idx);
for (var i=0; i<it; i++) {
// append slides to end
if (e.direction=="left") {
$t.find('.carousel-item').eq(i).appendTo($inner);
}
else {
$t.find('.carousel-item').eq(0).appendTo($inner);
}
}
}
});
but my simple Carousel distrupt and my multiItem Carousel not show any thing and not work
Try using owl carousel for your 'multi Item slide'.
If not share some code snippets so I can help.

Carousel to display full width of screen for small screens only

I have a carousel that is centered and only takes half the screen by adding this to the class "w-50". When the browser resizes to a smaller screen, like a mobile device, I want that carousel to take up the whole width of the screen. To do this I'm sure I'll need to find a way to change that to "w-100", but I'm not sure how to go about doing that.
I have tried to play around with #media in CSS, but haven't had any luck.
<div id="catalogueSelection">
<div id="catalogueCarousel" class="carousel slide w-50" data-ride="carousel" data-interval="5000">
<ol class="carousel-indicators">
<li data-target="#catalogueCarousel" data-slide-to="0" class="active"></li>
<li data-target="#catalogueCarousel" data-slide-to="1"></li>
<li data-target="#catalogueCarousel" data-slide-to="2"></li>
<li data-target="#catalogueCarousel" data-slide-to="3"></li>
<li data-target="#catalogueCarousel" data-slide-to="4"></li>
<li data-target="#catalogueCarousel" data-slide-to="5"></li>
<li data-target="#catalogueCarousel" data-slide-to="6"></li>
</ol>
<div class="carousel-inner">
<div class="carousel-item active">
<img id="franceImage" class="d-block w-100" src="../images/france.jpg">
<div class="carousel-caption countryCaption">
<h2>France</h2>
<p>See Products</p>
</div>
</div>
<div class="carousel-item">
<img id="italyImage" class="d-block w-100" src="../images/italy.jpg">
<div class="carousel-caption countryCaption">
<h2>Italy</h2>
<p>See Products</p>
</div>
</div>
<div class="carousel-item">
<img class="d-block w-100" src="../images/spain.jpg">
<div class="carousel-caption countryCaption">
<h2>Spain</h2>
<p>See Products</p>
</div>
</div>
<div class="carousel-item">
<img id="lebanonImage" class="d-block w-100" src="../images/lebanon.jpg">
<div class="carousel-caption countryCaption">
<h2>Lebanon</h2>
<p>See Products</p>
</div>
</div>
<div class="carousel-item">
<img id="southAfricaImage" class="d-block w-100" src="../images/south_africa.jpg">
<div class="carousel-caption countryCaption">
<h2>South Africa</h2>
<p>See Products</p>
</div>
</div>
<div id="southAmericaImage" class="carousel-item">
<img class="d-block w-100" src="../images/south_america.jpg">
<div class="carousel-caption countryCaption">
<h2>South America</h2>
<p>See Products</p>
</div>
</div>
<div id="domesticImage" class="carousel-item">
<img class="d-block w-100" src="../images/united_states.jpg">
<div class="carousel-caption countryCaption">
<h2>Domestic</h2>
<p>See Products</p>
</div>
</div>
</div>
<a class="carousel-control-prev" href="#catalogueCarousel" 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="#catalogueCarousel" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
#catalogueCarousel {
margin: auto;
border: 3px solid;
border-color: black;
}
.carousel-inner {
}
.carousel-item img {
height: 500px; !important
overflow: hidden;
opacity: 0.9;
opacity: 0.8;
}
.countryCaption h2 {
color: red;
font-family: 'Prosto One', cursive;
opacity: 1; !important
}
.countryCaption p{
color: darkred;
font-weight: bold;
font-family: 'Prosto One', cursive;
font-size: 20px;
opacity: 1; !important
}
Above is a snippet of the carousel html code, as well as it's stylesheet.
Any tips or ideas to help me resolve this is appreciated.
Thank you.
You can try using a combination of media queries and the !important rule.
Assuming 768px is your mobile breakpoint:
#media(max-width:768px){
#catalogueCarousel {
width: 100% !important;
}
}
Alternatavely you could use jQuery:
function resizeCarousel() {
if($window.width() < 768) {
$('#catalogueCarousel')
.removeClass('w-50')
.addClass('w-100');
} else {
$('#catalogueCarousel')
.removeClass('w-100')
.addClass('w-50');
}
}
resizeCarousel();
$window.resize(resizeCarousel);
You just need add media query for small device. Add below CSS in style sheet i hope it'll resolve your issue. Thanks
#media only screen and (max-width: 768px) {
#catalogueCarousel {
width: 100% !important;
}
}

Center responsive bootstrap carousel

I'm trying to fully customize a bootstrap carousel. I need to have it on the sidebar with the indicators at the bottom(outside the carousel). So far I was I able to make it work on large screens, but on smaller screens, the carousel refuse to be centered in the middle. Is there is a way to keep it centered (without using margin)? Thanks in advance
The current result:
The HTML of the element in question:
.other-articles {
padding: 1.2rem;
}
.other-articles>h3 {
font-size: .8rem;
}
.others {
padding: 1.2rem;
margin-top: 1.2rem;
margin-bottom: 1.2rem;
}
.other-places {
margin-top: 1.5rem;
}
.flex-other-articles {
display: flex;
flex-direction: row;
align-items: center;
flex-wrap: wrap;
}
.item-other-articles {
display: flex;
align-items: center;
border-bottom: 1px solid rgba(162, 163, 163, 0.344);
margin-top: .2rem;
}
.last-it-oth {
border-bottom: none !important;
}
.item-other-articles img {
border-radius: 3px;
margin-top: -.7rem;
height: 50px;
width: 56px;
flex-grow: 0;
flex-shrink: 0;
}
.item-other-articles-txt {
margin-left: .7rem;
}
.item-other-articles-txt>h6 {
font-size: .7rem;
}
.item-other-articles-txt>p {
font-size: .6rem;
}
#media (max-width:965px) and (min-width:780px) {
.other-articles {
text-align: center;
}
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
<div class="others block">
<h6>OTHER PLACE</h6>
<div class="other-place-dots">
<i class="fas fa-circle"></i>
<i class="fas fa-circle"></i>
<i class="fas fa-circle"></i>
</div>
<div class="the-mini-slider-on-the-sidebar container-fluid">
<div id="carouselExample" class="carousel slide" data-ride="carousel">
<div class="carousel-inner mini-carousel-img">
<div class="carousel-item">
<img class="d-block w-100 " src="https://i.imgur.com/lCcKhji.jpg" alt="First slide">
<div class="carousel-caption d-none d-md-block cap-1-black">
<div class="carr-text-img">
<h5>Ski Lifts</h5>
</div>
</div>
</div>
<div class="carousel-item">
<img class="d-block w-100" src="https://i.imgur.com/lCcKhji.jpg" alt="Second slide">
<div class="carousel-caption d-none d-md-block cap-1-black">
<div class="carr-text-img">
<h5>Ski Lifts</h5>
</div>
</div>
</div>
<div class="carousel-item active">
<img class="d-block w-100" src="https://i.imgur.com/lCcKhji.jpg" alt="Third slide">
<div class="carousel-caption d-none d-md-block cap-1-black">
<div class="carr-text-img">
<h5>Ski Lifts</h5>
</div>
</div>
</div>
<a class="carousel-control-prev" href="#carouselExample" 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="#carouselExample" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
<div class="carousel slide carousel-in-li" data-ride="carousel">
<ol class="carousel-indicators carousel-in-1">
<li data-target="#carouselExample" data-slide-to="0" class=""></li>
<li data-target="#carouselExample" data-slide-to="1" class=""></li>
<li data-target="#carouselExample" data-slide-to="2" class="active"></li>
</ol>
</div>
</div>
</div>
</div>

Bootstrap 4: Carousel Fade Transition Not Working

The below code worked perfectly fine for me using Bootstrap version 3. However, since upgrading to Bootstrap 4 Beta2 the fade transition does not work. It just jumps to the next image rather than a smooth transition:
HTML
<div id="carousel1" class="carousel fade" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carousel1" data-slide-to="0" class="active"></li>
<li data-target="#carousel1" data-slide-to="1"></li>
<li data-target="#carousel1" data-slide-to="2"></li>
</ol>
<div class="carousel-inner" role="listbox">
<div class="item active"><img src="images/a.jpg" alt="First slide image" class="center-block">
<div class="carousel-caption">
<h3>First slide Heading</h3>
<p>First slide Caption</p>
</div>
</div>
<div class="item"><img src="images/b.jpg" alt="Second slide image" class="center-block">
<div class="carousel-caption">
<h3>Second slide Heading</h3>
<p>Second slide Caption</p>
</div>
</div>
<div class="item"><img src="images/c.jpg" alt="Third slide image" class="center-block">
<div class="carousel-caption">
<h3>Third slide Heading</h3>
<p>Third slide Caption</p>
</div>
</div>
</div>
<a class="left carousel-control" href="#carousel1" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#carousel1" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
CSS
.carousel.fade {
opacity: 1;
}
.carousel.fade .item {
transition: opacity ease-out .7s;
left: 0;
opacity: 0; /* hide all slides */
top: 0;
position: absolute;
width: 100%;
display: block;
}
.carousel.fade .item:first-child {
top: auto;
opacity: 1; /* show first slide */
position: relative;
}
.carousel.fade .item.active {
opacity: 1;
}
JS
$(function(){
$('.carousel').carousel({
interval: 6000
});
});
Looking around and it seems that there has been a few issues with the recent bootstrap upgrade, any help would be appreciated.
As you have already noticed, quite a lot of things have been changed in Bootstrap 4. Let me walk you through the approach I took with the solution below.
.fade was renamed to .carousel-fade not to interfere with the default Bootstrap .fade class.
.item was renamed to .carousel-item, since that is the name in Bootsrap 4 for carousel items.
As the positioning of the slides is absolute now because of the fading effect, I added .embed-responsive embed-responsive-16by9 classes to .carousel-inner and also .embed-responsive-item to .carousel-item to preserve the height of the slide container and also to take care of the positioning of the slide items. (In case you want to use images with other aspect ratios, you should change the .embed-responsive-16by9 class. Defaults are listed here.)
So this would be my approach:
.carousel.carousel-fade .carousel-item {
display: block;
opacity: 0;
transition: opacity ease-out .7s;
}
.carousel.carousel-fade .carousel-item.active {
opacity: 1 !important;
}
<div id="carousel-fade" class="carousel carousel-fade" data-ride="carousel" data-interval="2000">
<ol class="carousel-indicators">
<li data-target="#carousel-fade" data-slide-to="0" class="active"></li>
<li data-target="#carousel-fade" data-slide-to="1"></li>
<li data-target="#carousel-fade" data-slide-to="2"></li>
</ol>
<div class="carousel-inner embed-responsive embed-responsive-16by9" role="listbox">
<div class="carousel-item embed-responsive-item active">
<img src="http://via.placeholder.com/1600x900/483D8B/ffffff?text=Slide%201" alt="First slide image" class="img-fluid">
<div class="carousel-caption">
<h3>First slide Heading</h3>
<p>First slide Caption</p>
</div>
</div>
<div class="carousel-item embed-responsive-item">
<img src="http://via.placeholder.com/1600x900/9400D3/ffffff?text=Slide%202" alt="Second slide image" class="img-fluid">
<div class="carousel-caption">
<h3>Second slide Heading</h3>
<p>Second slide Caption</p>
</div>
</div>
<div class="carousel-item embed-responsive-item">
<img src="http://via.placeholder.com/1600x900/FF1493/ffffff?text=Slide%203" alt="Third slide image" class="img-fluid">
<div class="carousel-caption">
<h3>Third slide Heading</h3>
<p>Third slide Caption</p>
</div>
</div>
</div>
<a class="carousel-control-prev" href="#carousel-fade" 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="#carousel-fade" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"></script>
Two more notes:
You can also set the change interval via the data-interval attribute of the .carousel.
The markup of the carousel controls have also been changed in Bootstrap 4.