Adding the Bootstrap4 CDN seems to break the animations on my website

<div class="mySlides fade">
  <img src="https://media.giphy.com/media/9JpsWBPgRtBDOYE6QB/source.gif" style="width:100%; height: 100%; border-radius: 0; ">
</div>

<div class="mySlides fade">
  <img src="https://media2.giphy.com/media/fRGq1cnopavJ7mKDYn/giphy.webp" style="width:100%; height: 100%; border-radius: 0; ">
</div>

<div class="mySlides fade">
  <img src="https://media1.giphy.com/media/lPRrCc9lQsOPa2qZiw/giphy.webp" style="width:100%; height: 100%; border-radius: 0; ">
   </div>

<a class="prev" onclick="plusSlides(-1)">&#10094;</a>
<a class="next" onclick="plusSlides(+1)">&#10095;</a>

</div>
  <div style="text-align:center">
  <span class="dot" onclick="currentSlide(1)"></span> 
  <span class="dot" onclick="currentSlide(2)"></span> 
  <span class="dot" onclick="currentSlide(3)"></span> 
</div>
    

<script>
    
    var slideIndex = 1;
    var timer = null;
    showSlides(slideIndex);
    
    function plusSlides(n) {
      clearTimeout(timer);
      showSlides(slideIndex += n);
    }
    
    function currentSlide(n) {
      clearTimeout(timer);
      showSlides(slideIndex = n);
    }
    
    function showSlides(n) {
      var i;
      var slides = document.getElementsByClassName("mySlides");
      var dots = document.getElementsByClassName("dot");
      if (n==undefined){n = ++slideIndex}
      if (n > slides.length) {slideIndex = 1}
      if (n < 1) {slideIndex = slides.length}
      for (i = 0; i < slides.length; i++) {
          slides[i].style.display = "none";
      }
      for (i = 0; i < dots.length; i++) {
          dots[i].className = dots[i].className.replace(" active", "");
      }
      slides[slideIndex-1].style.display = "block";
      dots[slideIndex-1].className += " active";
      timer = setTimeout(showSlides, 2500);
    } 
    </script>

This slider image has been customized with buttons and auto-slide functionality. Although some of the code may need refinement, I encountered an issue when trying to integrate Bootstrap4 CDN which caused certain div containers to shrink. Any suggestions on how to resolve this would be appreciated.

Answer №1

Substitute this bootstrap CSS

.fade:not(.show) { opacity: 1; }

Complete Code:

<!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.0">
    <title>Document</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="9af8f5f5eee9eee8fbeadaaeb4acb4aa">[email protected]</a>/dist/css/bootstrap.min.css" integrity="sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l" crossorigin="anonymous">

    <style>
        .fade:not(.show){
            opacity: 1;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="mySlides fade">
            <img src="https://media.giphy.com/media/9JpsWBPgRtBDOYE6QB/source.gif" style="width:100%; height: 100%; border-radius: 0 ">
        </div>
      
        <div class="mySlides fade">
            <img src="https://media2.giphy.com/media/fRGq1cnopavJ7mKDYn/giphy.webp" style="width:100%; height: 100%; border-radius: 0 ">
        </div>
      
        <div class="mySlides fade">
            <img src="https://media1.giphy.com/media/lPRrCc9lQsOPa2qZiw/giphy.webp" style="width:100%; height: 100%; border-radius: 0 ">
         </div>
      
      <a class="prev" onclick="plusSlides(-1)">&#10094;</a>
      <a class="next" onclick="plusSlides(+1)">&#10095;</a>
      
    </div>


    <div style="text-align:center">
        <span class="dot" onclick="currentSlide(1)"></span> 
        <span class="dot" onclick="currentSlide(2)"></span> 
        <span class="dot" onclick="currentSlide(3)"></span> 
    </div>
          
      
      <script>
          
          var slideIndex = 1;
          var timer = null;
          showSlides(slideIndex);
          
          function plusSlides(n) {
            clearTimeout(timer);
            showSlides(slideIndex += n);
          }
          
          function currentSlide(n) {
            clearTimeout(timer);
            showSlides(slideIndex = n);
          }
          
          function showSlides(n) {
            var i;
            var slides = document.getElementsByClassName("mySlides");
            var dots = document.getElementsByClassName("dot");
            if (n==undefined){n = ++slideIndex}
            if (n > slides.length) {slideIndex = 1}
            if (n < 1) {slideIndex = slides.length}
            for (i = 0; i < slides.length; i++) {
                slides[i].style.display = "none";
            }
            for (i = 0; i < dots.length; i++) {
                dots[i].className = dots[i].className.replace(" active", "");
            }
            slides[slideIndex-1].style.display = "block";
            dots[slideIndex-1].className += " active";
            timer = setTimeout(showSlides, 2500);
          } 
          </script>

    <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/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="690b06061d1a1d1b0819295d475f4759">[email protected]</a>/dist/js/bootstrap.bundle.min.js" integrity="sha384-Piv4xVNRyMGpqkS2by6br4gNJ7DXjqk09RmUpJ8jgGtD7zP9yug3goQfGII0yAns" crossorigin="anonymous"></script>
</body>
</html>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Easily remove data using jQuery

$("#results").after(data) In my code snippet above, I am using jQuery to add some database results after a DIV element with the ID "results" whenever a button is clicked. The issue I am facing is that each time the button is clicked, new results are added ...

Can a designated Angular2 component be customized with CSS in terms of its appearance while employing ViewEncapsulation?

I am looking for a way to dynamically change the appearance of Angular2 components with just the click of a button, making them appear completely different each time. This is similar to implementing various CSS "Skins" or "Themes". It would also be conveni ...

The updates made to a form selection using Ajax do not reflect in jQuery's .serialize or .val functions

When using the .load jQuery function to retrieve a form and place it in the document body, I encounter an issue. After loading the form, I manually change the select value and attempt to save the form using an ajax .post request. However, when trying to ...

Formatting ternary expressions in VueJS

VueJS is being utilized by me and it contains an expression as shown below: {{ item.recommendation ? "PS4" : "Xbox" }} Is there a way to make "PS4" appear in red color and "Xbox" in blue color within the expression by incorporating CSS ...

Unable to change placeholder in Material UI's Select Form

I'm having trouble modifying my SelectionForm. I need to update the color of the placeHolder image from red to a different color, but I can't find any properties or props on the material ui Docs to do so. Can someone assist me with this? https:/ ...

A guide on effectively selecting an element with the '@font-face' tag

I'm endeavoring to design a distinctive logo by utilizing a personalized font... and am keen on incorporating it into my CSS As an illustration: the identifier for my div element is "logo" Should I merely employ this code? #logo { font-family: ...

The process of displaying a single large image from a local file system using the elements input, img, and canvas

I am attempting to create a mobile-friendly picture upload webpage, but I keep experiencing memory issues causing the browser to crash when the picture is too large. Here's my code: <input type="file" id="testFile" /> <img src="" style="posi ...

Using Google App Engine with Stripe - Enable users to easily upload images for account identity verification directly through their browser using Javascript

After extensive research, I have been exploring how to enable direct browser uploads, particularly in the context of utilizing Stripe with Google App Engine, as discussed on this forum. The Stripe documentation also mentions the possibility of browser uplo ...

Selenium 2.20+ and its interactive hover feature

I want to trigger the :hover effect that is defined in my CSS file using Selenium. Despite it being a common task, none of the methods suggested in previous threads seem to work anymore. Here are some attempts I've made (unsuccessfully) Selenium-In ...

Is the JSON object sent over an AJAX call getting corrupted during a POST request?

While conducting tests on this application, The browser is sending a json as an array of approximately 500 objects via POST method. Upon inspecting the received json using a PHP server and debugger(xdebug), It appears that there are more elements in ...

What is the best way to input data into the verified full name box?

.html file executed code <input type="name" [(model)]="x.name" class="form-control" pattern="[a-z]" > Greetings to the members of Stack, I am in need of assistance. I am relatively new to Angular and I am looking for a way to validate the full nam ...

Ways to present YouTube recommendations as choices for engagement

Is there a way to show YouTube autofill suggestions in real-time as a user types? I have been using DisTube and the searchSongs option, but it only shows results after the text is input. I've observed bots like Soul Music successfully implementing thi ...

Tips for preventing HTTP Status 415 when sending an ajax request to the server

I am struggling with an AJAX call that should be returning a JSON document function fetchData() { $.ajax({ url: '/x', type: 'GET', data: "json", success: function (data) { // code is miss ...

Using controllerAs in an AngularJS directive allows for multiple instances to be created, each with the

In my form, I have directives that contain identical input fields, selects, and check boxes. To handle this, I created a directive with an isolate scope and controllerAs syntax using bindToController=true. The controller has a method triggered by an ngChan ...

Updating the value of a key in an object is not functioning as expected

There is a single object defined as requestObject: any = { "type": 'type1', "start": 0, "size": 10, "keywords": ['abcd','efgh'], filters: [], } Next, attempting to change the value for keyword, I updat ...

Making Explorer 11 wrap width with Flexbox

After implementing a simple code using flexbox, everything seemed to be working flawlessly on Firefox, Safari, Chrome, Edge, and Opera, but encountered issues with IE11. The problem arises with responsive frames containing images and text within a specific ...

Display content from two URLs in separate frames on a single HTML webpage

While the concept seems simple, I have never attempted it myself. Here is the code I tried: <html> <frameset cols="30%,70%"> <frame src="www.google.com" name="frame1"> <frame src="www.yahoo.com" name="frame2"> </frameset ...

How can I ensure that the 'popover' remains visible when hovering over both the anchorEl and the popover itself?

Check out this example of using material-ui at https://material-ui.com/utils/popover/#mouse-over-interaction Follow the steps outlined in the example above for material-ui at https://material-ui.com/utils/popover/#mouse-over-interaction When testing t ...

Is it possible to categorize a JSON object based on its properties and then count the occurrences of each property within

I have an array of objects containing booking information and I need to calculate the count of each booking item in every object. const arr = [ { "ID" : 1, "Name":"ABC", "Bookings":[ { & ...

Error: Unable to submit form with jQuery due to timeout issue - e[h] function not recognized

This question has surfaced on SO previously without any solution, maybe due to a different scenario Below is the form in question <form id="testSubmit" method="post" action="submit.php"> <!--The value of the following field will be collecte ...