Carousel sliding animation not working on Bootstrap 4.5.2 - html

I'm in the process of learning Bootstrap (v4.5.2), and wanted to create a simple carousel that slides automatically for my website. I went to Bootstrap documentation and copied the example code for a carousel with slides only (https://getbootstrap.com/docs/4.5/components/carousel/), and added some color and height to the divs to see if it was working. Here is the code:
.carousel-item {
height: 100px;
}
<!-- Bootstrap v4.5.2 CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<!-- JS, Popper.js, and jQuery -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js#1.16.1/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script>
<div id="carouselExampleSlidesOnly" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active" style="background-color:red;">
<img class="d-block w-100" src="..." alt="First slide">
</div>
<div class="carousel-item" style="background-color:blue;">
<img class="d-block w-100" src="..." alt="Second slide">
</div>
<div class="carousel-item" style="background-color:yellow;">
<img class="d-block w-100" src="..." alt="Third slide">
</div>
</div>
</div>
As you can see, everything works fine except the sliding animation. If instead of v4.5.2 I use v4.0.0 of bootstrap (with the exact same code) it works perfectly fine:
.carousel-item{
height: 100px;
}
<!--Bootstrap v4.0.0 CSS-->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<!-- JS, Popper.js, and jQuery -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js#1.16.1/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script>
<div id="carouselExampleSlidesOnly" class="carousel slide" data-ride="carousel" data-interval="3000" data-pause: "hover";>
<div class="carousel-inner">
<div class="carousel-item active" style="background-color:red;">
<img class="d-block w-100" src="..." alt="First slide">
</div>
<div class="carousel-item" style="background-color:blue;">
<img class="d-block w-100" src="..." alt="Second slide">
</div>
<div class="carousel-item" style="background-color:yellow;">
<img class="d-block w-100" src="..." alt="Third slide">
</div>
</div>
</div>
But I would like to use the latest version of the framework if possible.
I have noticed that even in the documentation pages, in v4.0.0 sliding animation works on the example slides (https://getbootstrap.com/docs/4.0/components/carousel/), but not in v4.5.2 (https://getbootstrap.com/docs/4.5/components/carousel/), so I'm guessing this might be a bug from the newer version? Or maybe as I'm a newbie I'm doing something wrong? Thanks in advance for your answers, I hope the question is clear and well written, it's my first time asking somtehing over here.

After hours of research I think I just found out what was causing the error. It seems like on the newest updates some bootstrap code has the feature (prefers-reduced-motion), a CSS media feature that is used to detect if the user has requested that the system minimize the amount of non-essential motion it uses. By using this feature the browser will check the configuration of your operating system, and wil display the animations accordingly.
So If you have reduced animations on your operating system configuration then the browser will not show some animations, like in this case. To be able to see the animation you must do the following:
OSX: Settings > General > Accessibility > Reduce Motion
IOS: System Preferences > Accessibility > Display > Reduce Motion
Windows: Settings > Ease of Access > Show animations in Windows > ON
For more info about this check out this issue on github.
Working from chrome using windows, I turned ON the "show animations in windows" button and everything works perfectly now. Hope this helps guys, and sorry if it was a trivial issue.

Slide Animation issue on Bootstrap v4.5.2 & v5.1 (https://getbootstrap.com/docs/4.5/components/carousel/)
I manage to fix it using additional CSS
<style>
.carousel-item{
transition: -webkit-transform .6s ease;
transition: transform .6s ease;
transition: transform .6s ease,-webkit-transform .6s ease;
}
</style>
then the animation slide started working, I don't need to explain reading the code tells everything.

Related

Why do my carousel slides just display one under the other?

When I hit run or preview in a browser, I am using Chrome, a static view of all three slides stacked 1-3 is displayed. So they do not toggle through each one.
This is only not working on codeply which I use often. It does work on codepen and it does work once I add it to my html and CSS files through atom code editor. Its only codeply that it will not run and I have javascript and bootstrap packages installed in codeply.
.carousel-item {
height: 150px;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<div id="carouselExampleSlidesOnly" class="carousel slide" data-bs-ride="carousel" data-interval="1000">
<div class="carousel-inner">
<div class="carousel-item active" style="background-color: red;">
<img src="https://via.placeholder.com/600x150" class="d-block w-100" alt="First Slide">
</div>
<div class="carousel-item" style="background-color: yellow;">
<img src="https://via.placeholder.com/600x150/ff0000" class="d-block w-100" alt="Second Slide">
</div>
<div class="carousel-item" style="background-color: blue;">
<img src="https://via.placeholder.com/600x150" class="d-block w-100" alt="Third Slide">
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
Disregard this question. I wasn't saving my selected framework which was latest bootstrap version in codeply. It works fine.

Carousel stop as soon as mouse hover over it, can bootstrap be the problem? i am using bootstrap 4.1.3

Carousel stop on mouse hover i did try to set data-pause = "null" but
then the hole carousel stop working. If i try to make data pause null !important the also the hole carousel stop working. i added all the necessary bootstrap and script but to no avail it still stop cascading as soon as the mouse hover over the carousel.
.carousel-item:before {
-webkit-box-shadow: inset 0 0 20rem rgba(0, 0, 0, 1);
box-shadow: inset 0 0 20rem rgba(0, 0, 0, 1);
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
content: "";
}
.w-100 {
width: 100% !important;
height: 75vh;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<!-- Bootstrap Core CSS -->
<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>
</head>
<body>
<div class="container-sm">
<div id="carouselSlidesOnly" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img class="w-100" src="https://www.w3schools.com/bootstrap/la.jpg" alt="1st slide">
</div>
<div class="carousel-item ">
<img class="w-100" src="https://www.w3schools.com/bootstrap/chicago.jpg" alt="2nd slide">
</div>
<div class="carousel-item ">
<img class="w-100" src="https://www.w3schools.com/bootstrap/ny.jpg" alt="3rd slide">
</div>
</div>
</div>
</div>
</body>
<!-- jQuery -->
<script src="js/jquery.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="js/bootstrap.min.js"></script>
</html>
use the term data-pause=false just as:
</head>
<body>
<div class="container-sm">
<div id="carouselSlidesOnly" class="carousel slide" data-ride="carousel" data-pause="flase">
<div class="carousel-inner">
<div class="carousel-item active">
<img class="w-100" src="https://www.w3schools.com/bootstrap/la.jpg" alt="1st slide">
</div>
<div class="carousel-item ">
<img class="w-100" src="https://www.w3schools.com/bootstrap/chicago.jpg" alt="2nd slide">
</div>
<div class="carousel-item ">
<img class="w-100" src="https://www.w3schools.com/bootstrap/ny.jpg" alt="3rd slide">
</div>
</div>
</div>
</div>
</body>
<!-- jQuery -->
<script src="js/jquery.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="js/bootstrap.min.js"></script>
</html>

Why is my carousel not loading to my webpage?

I am having trouble getting my carousel to load into my webpage.
I have played around with adding CSS height/width to the carousel div and even tried adding height to the contained img elements, but must be failing somewhere.
All help is much appreciated. Here's the notable code (cut from a larger document)...
IN MY HEAD:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
AT THE BOTTOM OF MY BODY:
<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>
THE CAROUSEL:
<div id="carousel" class="carousel slide" data-right="carousel">
<div class="carousel-inner" roll="listbox">
<div class="carousel-item">
<img class="d-block w-100" src="https://www.neptunus.co.uk/app/uploads/2019/05/evolution-pieterschelte-rotterdam-76997-1.jpg" alt="Temporary structures built on the Pioneering Spirit catamaran">
<div class="carousel-caption">
<h3>Pioneering Spirit</h3>
<p>Weeks at sea produced thousands of square meters of temporary hospitality structures.</p>
</div>
</div>
<div class="carousel-item">
<img class="d-block w-100" src="https://www.eventindustrynews.com/wp-content/uploads/2018/03/Neptunus-Image-2.jpg" alt="Main structure for England's Rugby World Cup.">
<div class="carousel-caption">
<h3>Rugby World Cup</h3>
<p>Twickenham proves annual demand for White Rose Crew, but this year was special.</p>
</div>
</div>
<div class="carousel-item">
<img class="d-block w-100" src="https://www.neptunus.co.uk/app/uploads/2019/05/evolutioniii-thales-farnborough1.jpg" alt="A three story structure for Farnborough Airshow.">
<div class="carousel-caption">
<h3>Thales</h3>
<p>Our favourite biannual build of the worlds largest airshow.</p>
</div>
</div>
<div class="carousel-item">
<img class="d-block w-100" src="https://s3.eu-west-2.amazonaws.com/luxurylondon.co.uk-storage-bucket-001/images/articles-body/603/masterpiece-2019-london.jpg" alt="Masterpiece Arts Fair, Chelsea.">
<div class="carousel-caption">
<h3>Masterpiece</h3>
<p>We are proud to be an integral part of this incredible transformation year in, year out.</p>
</div>
</div>
<div class="carousel-item">
<img class="d-block w-100" src="https://ichef.bbci.co.uk/news/1024/cpsprodpb/62AF/production/_112536252_cdf_200420_cardiffhospital18.jpg" alt="Emergancy hospital built in the Pricipality Stadium.">
<div class="carousel-caption">
<h3>Emergancy Covid-19 Field Hospital</h3>
<p>Helping turn The Pricipality Stadium into Wales largest hospital in just 10 days.</p>
</div>
</div>
</div>
</div>
Check jquery cdn and check for the latest CDN.Using bootstrap given CDN will not work for you
I figured it out the minute I posted this.
I hadn't set any of the slides to "active".
Easy fix :)

Angular 9 Bootstrap carousel remains still with no effects

In HTML, all is properly ranged and directly equal to the original Bootstrap 4 website:
<div id="carouselExampleSlidesOnly" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img class="d-block w-100" src="../../assets/images/background/promo-bg.jpg" alt="Primera diapositiva">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="../../assets/images/background/promo-bg-2.jpg" alt="Segunda diapositiva">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="../../assets/images/background/promo-bg-3.jpg" alt="Tercera diapositiva">
</div>
</div>
</div>
styles.css:
/* You can add global styles to this file, and also import other style files */
#import '../node_modules/bootstrap/dist/css/bootstrap.min.css';
/*#import '../node_modules/bootswatch/dist/yeti/bootstrap.min.css';*/
#import '../node_modules/font-awesome/css/font-awesome.min.css';
#import '../node_modules/alertifyjs/build/css/alertify.min.css';
#import '../node_modules/alertifyjs/build/css/themes/bootstrap.min.css';
#import '../node_modules/ngx-bootstrap/datepicker/bs-datepicker.css';
/*Los imports del tema importado*/
#import '../src/assets/css/theme-1.css';
/*#import '../src/assets/fontawesome/js/all.js';*/
#import '../src/assets/plugins/pe-icon-7-stroke/css/pe-icon-7-stroke.css';
#import '../src/assets/plugins/flexslider/flexslider.css';
The carousel in the HTML page stays still, and I don't get why. All the needed code is already included in the components of the Angular. I took the carrousel from https://getbootstrap.com/docs/4.0/components/carousel/
But still, it does not work.
I edit to add the Js calls at the end of home.component.html:
Of course. At the end of the home.component.html there is this code: <!--
jQuery first, then Popper.js, then Bootstrap JS -->
<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.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</div>

My carousel is not working for no specific reason

I have a carousel on angular web app which is supposed to move images on intervals but it is not working as expected, I can not figure out the reason behind --
here's my code
<div id="section1" class="carousel slide" data-ride="carousel" data-interval="1000">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#section1" data-slide-to="0" class="active" ></li>
<li data-target="#section1" data-slide-to="1" ></li>
<li data-target="#section1" data-slide-to="2" ></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="img1.jpg" alt="...">
<div class="carousel-caption">
<!-- <h3>Caption Text</h3> -->
</div>
</div>
<div class="item ">
<img src="img2.jpg" alt="...">
<div class="carousel-caption">
<!-- <h3>Caption Text</h3> -->
</div>
</div>
<div class="item ">
<img src="img3.jpg" alt="...">
<div class="carousel-caption">
<!--h3>Caption Text</h3-->
</div>
</div>
</div>
</div>
Everything seems fine, what bootstrap plugin did you used, because the class you have applies requires bootstrap plugin. Please let me know which bootstrap plugin did you use...
try this CDN for bootstrap plugin. It works perfectly with mine
<!--Bootstrap CSS-->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!--Bootstrap jquery-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<!--Bootstrap javascript-->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>