"Initial loading issue with bootstrap carousel causes slides not to slide smoothly

I am currently working on implementing a slider carousel using Bootstrap. Although the 'active' image loads successfully, the controls and slide functionality are not working as expected. Initially, I believed this exercise would be straightforward practice, but I have encountered a hurdle. I have shared the entire HTML document, and while the functionality is working fine, I don't think the issue lies with the boostrap.css link.

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8" name="" content="Trey's Personal Website.">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  <title>Trey Coggins | Personal Website</title>

<script type="text/javascript" src="script/index.js"></script>

<link rel="stylesheet" type="text/css" href="styles/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet"  type="text/css" href="styles/index-style.css">

</head>

<body>

  <header>
   
    <nav class="navbar navbar-expand-md navbar-dark bg-dark">
      <a class="navbar-brand" href="">Trey Coggins</a>

      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarCollapse">
        <span class="navbar-toggler-icon"></span></button>

      <div class="collapse navbar-collapse" id="navbarCollapse">
        <ul class="navbar-nav">
          <li class="nav-item">
            <a class="nav-link" href="">Home</a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="">About</a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="">Contact</a>
          </li>
        </ul>
      </div>
    </nav>

    <div id="carouselControls" class="carousel slide" data-ride="carousel">
      <div class="carousel-inner">

        <div class="carousel-item active">
            <img class="d-block w-100" src="img/bricks.jpg" alt="">
              <div class="carousel-caption">
                <h2>Let's build something together!</h2>
              </div>
        </div>

        <div class="carousel-item">
          <img class="d-block w-100" src="img/woods.jpg" alt="">
            <div class="carousel-caption">
              <h2>Take a walk in the woods</h2>
            </div>
        </div>

        <div class="carousel-item">
          <img class="d-block w-100" src="img/stone.jpg" alt="">
            <div class="carousel-caption">
              <h2>Elevate yourself to the next level</h2>
            </div>
        </div>
      </div>

      <a class="carousel-control-prev" href="#carouselControls" 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="#carouselControls" role="button" data-slide="next">
        <span class="carousel-control-next-icon" aria-hidden="true"></span>
        <span class="sr-only">Next</span>
      </a>

    </div>
  </header>

  <div class="container text-center">
    <div class="row">
      <div class="col-md-4">
        <img class="rounded-circle" src="img/trey-court-headshot.jpg" alt="Trey & Courtney">
        <h2>Trey & Courtney</h2>
        <p>She's the love of my life!</p>
        <p><a class="btn btn-secondary" href="#" role="button">See more &raquo;</a></p>
      </div>

      <div class="col-md-4">
        <img class="rounded-circle" src="img/tootsie-smile.jpg" alt="Mama Tootsie">
        <h2>Bodhi & Tootsie</h2>
        <p>These two keep us young!</p>
        <p><a class="btn btn-secondary" href="#" role="button">See more &raquo;</a></p>

      </div>

      <div class="col-md-4">
        <img class="rounded-circle" src="img/royal-hearts.jpg" alt="Royal Flush">
        <h2>Poker</h2>
        <p>Join the action!</p>
        <p><a class="btn btn-secondary" href="#" role="button">See more &raquo;</a></p>

      </div>
    </div>
  </div>


</body>
</html>

Answer №1

Could you please provide your HTML page along with all its code? I am interested in verifying whether you have correctly integrated the bootstrap's javascript/CSS file.

In case you have not included JavaScript, here are the necessary javascript files that should be added to your HTML code:

<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="bbcbd4cbcbdec995d1c8fb8a958a8d958b">[email protected]</a>/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>

Answer №2

    <div id="myCarousel" class="carousel slide" data-ride="carousel">
        <ol class="carousel-indicators">
            <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
            <li data-target="#myCarousel" data-slide-to="1"></li>
            <li data-target="#myCarousel" data-slide-to="2"></li>
          </ol>
        <div class="carousel-inner">
            <div class="carousel-item item active">
                <img class="col-lg-7 d-block w-100" src="img/bricks.jpg" alt="">
                <div class="carousel-caption">
                    <h2>Let's create something amazing together!</h2>
                </div>
            </div>
            <div class="carousel-item item">
                <img class="d-block w-100" src="img/woods.jpg" alt="">
                <div class="carousel-caption">
                    <h2>Embark on a journey through the woods</h2>
                </div>
            </div>
            <div class="carousel-item item">
                <img class="d-block w-100" src="img/stone.jpg" alt="">
                <div class="carousel-caption">
                    <h2>Rise to new heights</h2>
                </div>
            </div>
        </div>

        <a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
            <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
            <span class="sr-only">Previous</span>
        </a>

        <a href="#myCarousel" role="button" data-slide="next" class="right carousel-control">
           <span class="glyphicon glyphicon-chevron-right"></span>
      <span class="sr-only">Next</span>
        </a>

    </div>

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

What are the best practices for integrating PrimeVue with CustomElements?

Recently, I decided to incorporate PrimeVue and PrimeFlex into my Vue 3 custom Element. To achieve this, I created a Component using the .ce.vue extension for the sfc mode and utilized defineCustomElement along with customElements.define to compile it as a ...

VueJS is utilized to duplicate the innerHTML output value

Currently diving into the world of Vue, I encountered an issue while rendering an HTML text. My component template is a WYSIWYG editor. <template> <div id='editor_container'> <slot name="header" /> <div id='editor ...

Adjusting the width of a select box to match the size of its child table using CSS

Within my Vue application, I've implemented a select box that contains a table component. When the select box is clicked, the table becomes visible in a container. However, I'm facing an issue where I can't dynamically adjust the width of th ...

Browse through content without displaying the page title on the navigation bar and without the use of frames

When I sign into certain websites, I have noticed that the address displayed is often something like this: https://examplesite.com/access Even though all the links on the landing page are clickable and functional, their corresponding addresses never show ...

Unable to establish a hyperlink to specific section of page using MUI 5 Drawer

When attempting to link to a specific part of my first page upon clicking the Shop button in the navigation Drawer, nothing happens: https://i.stack.imgur.com/FUQCp.png This snippet shows the code for the MUI 5 Drawer component: <Drawer anch ...

Differences in font sizes across various browsers on Mac devices

In the given scenario, a navigation bar is displayed. The elements of this navigation bar have varying widths, but when combined together, their total width matches that of their container element, which is the ul. The problem arises when viewing the navig ...

Unable to display <div> elements from CSS within the Wordpress Text Widget

Having trouble displaying a <div> from CSS in a Text Widget on Wordpress. <div class=”deffgall-cutlure” ></div> style.css .deffgall-cutlure { display:block; position:relative; width:100px; height:100px; backgrou ...

Is it possible to achieve a seamless interaction by employing two buttons that trigger onclick events to alternately

I have a specific goal in mind: I want to create two buttons (left and right) with interactive cursors. The left button should initially have a cursor of "not-allowed" on hover, indicating that it cannot be clicked at the beginning. When the right button ...

Adjust the color of the text as it scrolls by

As I work on developing my website using the Neve Theme on WordPress, I have encountered an issue with customizing the header block. I am using a plugin to set a background color for the header after scrolling 100px down the page, but this makes the text h ...

App.controller attributes in HTML tags are not receiving the value of the HTML variable

In the process of developing a simple student-teacher web application, I am utilizing AngularJS to handle the front-end. Within my JavaScript file, there are two app controllers - one for fetching student data and another for retrieving subjects assigned t ...

Which html parsing tool is capable of processing encoding?

The journey begins -- I have a file saved on my computer that is an HTML page. When I view it in a regular web browser, the correct characters are displayed regardless of the encoding used. Then comes the challenge -- my task is to load the same file, par ...

ng-bootstrap dropdown menu not responding to click events

I recently implemented a button dropdown menu, which I directly borrowed from this ng-bootstrap example. Although the dropdown functionality is working fine, I encountered an issue when trying to add a click handler to the dropdown buttons. Despite my eff ...

Conceal the scrollbar when the expansion panel is in its collapsed state

One issue I am encountering is that the scroll-bar appears when the expansion panel is collapsed, but not when it's expanded. Here are the references: Collapsed Expanded <mat-expansion-panel class="panel"> <mat-expansion-panel-he ...

When a website is deployed to an application, the process includes MVC bundling and managing relative CSS image paths

When trying to convert relative image paths to absolute paths, there are numerous queries on stackoverflow addressing this issue. For example, take a look at this thread: MVC4 StyleBundle not resolving images This question recommends using new CssRewrite ...

What is the main purpose of using the CSS transform:translate() property?

When CSS3 introduced animations with transition properties, it gave developers two main ways to change the position of an element. The first method involves setting the element's position as absolute and adjusting the left, right, top, and bottom prop ...

Scraping a website where the page source doesn't match what is displayed on the browser

Imagine I'm interested in extracting marathon running time data from a specific website: Upon inspecting the webpage using Google Chrome, I noticed that the desired data is not directly visible in the page source. Although I have successfully scraped ...

Transmitting the User's Geographic Location and IP Address Securely in a Hidden Input Field

I'm looking to enhance my HTML form by retrieving the user's IP address and country when they submit the form. How can I achieve this in a way that hides the information from the user? Are there any specific elements or code additions I need to ...

The button is not centered within the grid container

I need assistance centering the button within a Grid layout using Material-UI <Grid container style={{backgroundColor:'green'}} alignItems="center" justify="center" > <Grid alignItems="center" justify=&q ...

What steps can be taken to resolve the issue of Ajax not retrieving any data from

I'm struggling to identify the error in this code. I have created a search bar and implemented AJAX to automatically fetch data. Here is the HTML file: <!DOCTYPE html> <html> <head> <title></title> <script ...

Efficiently reducing the size of a CSS selector string with javascript

Is there a library that already performs this function? I've only been able to find online tools. The reason I am interested in accomplishing this task using JavaScript is because I need to ensure that the strings a > b, a and a> b,a are conside ...