Issue with Bootstrap Image Slider Carousel functionality not functioning as expected

I am facing an issue with my Django website where I am trying to display images using an image slider carousel. However, the code is not functioning as expected. Instead of a carousel, the images are appearing stacked on top of each other.

https://i.sstatic.net/O0qom.png

This is my HTML code:

<div class="section">
    <div class="container">
    <div class="row justify-content-between">
    <div class="col-lg-7">
        <div class="img-property-slide-wrap">
        <div class="img-property-slide">
        <img src="{{ object.image1.url }}" alt="Image" class="img-fluid">
        <img src="{{ object.image2.url }}" alt="Image" class="img-fluid">
        <img src="{{ object.image3.url }}" alt="Image" class="img-fluid">
        </div>
        </div>
    </div>
    </div>
</div>

This is my style.css code:

.img-property-slide-wrap {
  position: relative; }
  .img-property-slide-wrap .tns-outer .tns-inner {
    padding-bottom: 100px !important; }
  .img-property-slide-wrap .tns-nav {
    position: absolute;
    left: 50%;
    -webkit-transform: translateX(-50%);
    -ms-transform: translateX(-50%);
    transform: translateX(-50%);
    bottom: 40px;
    z-index: 2; }
    .img-property-slide-wrap .tns-nav button {
      background: none;
      border: none;
      display: inline-block;
      margin: 2px;
      position: relative; }
      .img-property-slide-wrap .tns-nav button:active, .img-property-slide-wrap .tns-nav button:focus {
        outline: none; }
      .img-property-slide-wrap .tns-nav button:before {
        position: absolute;
        content: "";
        width: 7px;
        height: 7px;
        border-radius: 50%;
        background-color: rgba(0, 0, 0, 0.2);
        right: 0;
        -webkit-transition: .3s all ease;
        -o-transition: .3s all ease;
        transition: .3s all ease; }
      .img-property-slide-wrap .tns-nav button.tns-nav-active:before {
        background-color: #1f6f8b; }

Answer №1

Your code needs adjustments for the carousel to function correctly. Take a look at the carousel example in the Bootstrap documentation for guidance: Carousel Example

Below is a revised version of the code that displays images in carousel format. Remember to include the necessary Bootstrap dependencies in your HTML.

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1, shrink-to-fit=no"
    />
    <link
      rel="stylesheet"
      href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"
    />
    <title>Bootstrap Image Carousel</title>
  </head>
  <body>
    <div class="section">
      <div class="container">
        <div class="row justify-content-between">
          <div class="col-lg-7">
            <div id="imageCarousel" class="carousel slide" data-ride="carousel">
              <div class="carousel-inner">
                <div class="carousel-item active">
                  <img
                    src="https://images.pexels.com/photos/147411/italy-mountains-dawn-daybreak-147411.jpeg?auto=compress&cs=tinysrgb&w=1200"
                    class="d-block w-100"
                    alt="Image 1"
                  />
                </div>
                <div class="carousel-item">
                  <img
                    src="https://images.pexels.com/photos/36717/amazing-animal-beautiful-beautifull.jpg?auto=compress&cs=tinysrgb&w=1200"
                    class="d-block w-100"
                    alt="Image 2"
                  />
                </div>
                <div class="carousel-item">
                  <img
                    src="https://images.pexels.com/photos/247599/pexels-photo-247599.jpeg?auto=compress&cs=tinysrgb&w=1200"
                    class="d-block w-100"
                    alt="Image 3"
                  />
                </div>
              </div>
              <a
                class="carousel-control-prev"
                href="#imageCarousel"
                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="#imageCarousel"
                role="button"
                data-slide="next"
              >
                <span
                  class="carousel-control-next-icon"
                  aria-hidden="true"
                ></span>
                <span class="sr-only">Next</span>
              </a>
            </div>
          </div>
        </div>
      </div>
    </div>

    <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></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

I prefer not to receive the parent's opacity settings when styling a child element in CSS

Is there a way to prevent the child element from inheriting the opacity of the parent in CSS? I have a parent div and a child div inside it. I want to set the opacity for the parent div, but not have it affect the child div. Does anyone know how I can ac ...

Disregard IDs when linting CSS in ATOM

Is there a way to configure csslint in Atom to exclude "ids" and prevent the warning "Don't use IDs in selectors" from appearing? Update: Despite my question being flagged as potentially duplicate, I delved deeper in my own research and ultimately fo ...

Issue with alignment of Bootstrap inline form field on top and bottom levels

I seem to be encountering an issue highlighted in the image below: My goal is to have the state dropdown perfectly aligned with the top and bottom edges of the other two controls. Here's the code snippet I've used to create this section of the i ...

Styling does not seem to apply to inner components in NEXTJS

I am attempting to create a ChatGPT replica using Next.js and Tailwind CSS. My focus is currently on the main chat screen, where each message is displayed using a separate Message component with its own styling. However, I am facing an issue where the styl ...

Issue encountered: difficulty with vertical alignment in table cell containing both text input and image

I am facing an issue with aligning two items (an input text and an image) within a cell of a table. Despite trying various methods like using vertical-align:middle, margin top, padding, and setting height to 100%, I haven't been able to achieve the de ...

Can CSS be used to consistently position content in a specific manner?

I previously inquired about a similar issue and received an excellent solution. Here is my jsbin http://jsbin.com/nuwagibayo/1/edit?html,css,output where I encountered the following scenario: The positioning of 12.50 seems slightly awkward in its current ...

Repositioning with Flexbox: shifting the middle element to a new line

I have a flex item that contains three divs. ┌────────────────────────────────────────┐ | WRAPPER | | ┌─────────┬─ ...

Summing Up Values in Jquery Loop Through Table Rows

I am facing a challenge with a table that contains a textfield for inputting numeric values. This textfield is part of a repeated row table, with the ID 'amount'. My goal is to calculate the sum of all values entered in the textfields with the ID ...

Having trouble with my WordPress theme not recognizing my CSS file

My file path is displayed below: D:\web server\blog.dev.cc\wp-content\themes\ablog\css for java script file path D:\web server\blog.dev.cc\wp-content\themes\ablog\assets\js Despite checking ...

Ways to adjust the number of columns in a div using Bootstrap for varying screen sizes of larger devices

https://i.sstatic.net/1nHlm.pngI am new to coding and exploring html, css, and bootstrap. Is it possible to assign varying numbers of columns to a div based on different resolution ranges for larger devices? Specifically looking at the "lg" range which co ...

Using the react-bootstrap library, I have successfully integrated a Navbar

The navigation bar below is not functioning properly, and the container is causing the links to lead to a 404 error page. I have attempted writing it in various formats: <Nav.Link href="" >Name</Nav.Link> <Nav.Link href={"&qu ...

Pick the item when the checkbox is selected

I am currently attempting to toggle the visibility of a select element based on whether a checkbox is checked or not, but it doesn't seem to be working as expected. My desired functionality is for the select element to be hidden upon page load and th ...

How to delete strings from a variable using PHP

I am currently working on my project with the "AngularJS" invoice template. The issue I am facing is that the currency symbol appears in the sub total text box. While this is fine for display purposes, when I input data into the database, it also adds the ...

How can I determine if a page is being rendered in Standards mode or Quirks mode by IE7?

Having some issues with CSS on a webpage. The code is valid and adheres to Strict HTML standards. It displays correctly in most browsers, but I'm experiencing problems in IE (specifically version 7). Is there a way to determine if the page is being re ...

problem with creating a django template script

Hello, I am currently working on a code that is responsible for executing various functions within the template. I have utilized scripts to verify these functions using if-else statements and for loops. However, I am encountering some errors during this pr ...

Please ensure that all default tags (checkboxes) have a data-id or id assigned to them

When attempting to update todo tags using patch, I encountered an issue where the id or data-id is missing from pages created by Onenote with default todo tags. How can I target the element with patch? For example, on this page, the data-tag="to-do" does ...

The total height of the document's body in jQuery is not equal to the sum of the viewport height and the window's scroll top position at the bottom of the document

Why does the document height appear smaller than the window scroll top value plus the viewport height when I reach the end of the document? Shouldn't they be equal? I've been struggling with this issue for hours and can't seem to figure it o ...

Utilizing Font Awesome for social icons in a Vue component display

Currently, I'm in the process of building my own website and making the switch from traditional HTML, CSS, and JS to using VueJs. I've hit a roadblock when trying to transfer some code from my original HTML file to a Vue JS component, specificall ...

Ways to prevent a div containing a lengthy content string from extending beyond other divs

Check out my Codepen project here Here is the HTML code for my personal website: <div id="splash" class="divider"> <h1 class="text-center text-uppercase">vincent/rodomista</h1> <p class="text-center text uppercase">Full Stack ...

Ways to change the default blue dropdown color in the Chrome browser

When you click on the drop-down menu, a blue color appears when hovered over. I want it to be red instead, but for some reason, it's not working in Chrome browser. Here is the CSS class that I have used: option:checked { box-shadow: 0 0 10px 100p ...