Solution for the first problem with Bootstrap 4 carousel indicators being active

While working with bootstrap 4, I have implemented custom arrows for both left and right navigation.

One issue I encountered is that Bootstrap does not properly check li elements to assign the active class, instead it only adds the class to the first element it encounters.

This problem leads to an incorrect state of the active slide being displayed.

For example:

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

should be:

https://i.sstatic.net/3VMBa.png

To reproduce this issue, visit:

<div class="carousel-indicators">
    <img class="carousel-arrows carousel-arrow-left" src="/img/icons/arrow-circle-left.svg" onclick="carouselID.carousel('prev')" alt="previous" />
    <li data-target="#carousel"  data-slide-to="0"></li>
    <li data-target="#carousel"  data-slide-to="1"></li>
    <li data-target="#carousel"  data-slide-to="2></li>
    <img class="carousel-arrows" src="/img/icons/arrow-circle-right.svg" onclick="carouselID.carousel('next')" alt="next" />
</div>

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

Answer №2

The problem was fixed by enclosing the carousel-indicators within another div element.

<div class="wrapper-div">
 .. icon arrow left
  <div class="carousel-indicators">
     <li></li>
     <li></li>
  </div>
 .. icon arrow right
</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

Show a collection of items surrounding an image in order to form a circular menu

For my website, I'm looking to implement a circular navbar that will surround the user avatar. Using ul and li elements, I have created various options that are necessary. Is there a way to position all the navItems around the bottom half of the avata ...

Bootstrap modal causing issues with jquery Tablesorter scrolling functionality

I have implemented a table using the jQuery tablesorter in a Bootstrap modal. Initially, everything was working fine with sorting and all functionalities. However, when I added the scrolling widget, the modal started to appear blank with nothing displayi ...

Exploring and Modifying CSS Styles in Element Properties

Struggling to remove a 50px gap on my website. It's built on Joomla 1.5 and the white space is highlighted in orange below. When I inspect element using Chrome, it shows a margin-bottom: 50px but doesn't specify the location. Any tips on how to ...

Is there a way to automatically recalculate the "Total Price" when the input values are adjusted?

Whenever I add an item to the cart, it gets appended to the row in the shopping cart, and the price adjusts accordingly. However, I'm having trouble getting the price to adjust whenever I change the input values (input type: "number"). I can't se ...

Tips for inserting the <style> element within a Vue.js component

Currently working with Vue.js v2, I am facing an issue where I have a CSS stylesheet stored as a string in a variable. import sitePackCss from '!!raw-loader!sass-loader!../../app/javascript/styles/site.sass'; I am trying to generate a <style& ...

How do I overwrite this calculation using JQuery?

I have a website: link There are two pages on my site that have the same div elements... I want one page to perform a certain calculation on the divs, and another page to perform a different calculation... New JavaScript Code: jQuery(document).ready(fu ...

Issue with click function not activating in Chrome when using Angular 6

I am facing an issue where the (click) function is not triggering in my select tag when I use Google Chrome, but it works fine in Mozilla. Below is my code: <div class="col-xl-4 col-lg-9"> <select formControlName="deptId" class="form-control ...

Changing between two images using HTML and CSS

I am currently designing a WordPress theme and I would like to create an effect where two different thumbnail images switch on hover. The code that I have come up with so far looks something like this : <a class="thumb" href="posturl"> <img src= ...

Ways to extend the default hover duration for the <a> title attribute (tooltip)

Is there a method to extend the length of time that a tool tip appears when using the title attribute in an HTML tag? In Internet Explorer, it seems to vanish after only around 5 seconds. Is there a way to make it last longer? ...

Utilizing Bootstrap 4 icons in Laravel along with VueJS: A comprehensive guide

After successfully installing Bootstrap icons into my Laravel/VueJS application using NPM following the guidelines provided at , I am unsure of what the next step should be. If I wish to utilize the svg element in a blade template, is it necessary to comp ...

The spacing within the table's <tr> elements does not get altered

I am struggling to add a small space in the table <tr> but my attempts have not been successful. How can I resolve this issue? Please refer to the image below for clarification: https://i.sstatic.net/HXdhq.png .panel-booking .panel-body { pad ...

Having trouble hiding the hamburger menu depending on the screen width

I'm trying to figure out how to hide the hamburger menu when the screen width exceeds 400px. You can check out the site at damf.co Currently, the hamburger menu appears when the screen width is less than 400px. If you click on it and then expand the ...

JavaScript text spacing

I'm currently utilizing the JavaScript code snippet below to clear out the existing content within a div element in order to insert new elements. However, I've encountered an issue where once the div is cleared, its CSS styling is lost. I am atte ...

Add a custom filter to the active route for a stylish look

I am trying to dynamically change the color of elements in my navbar by creating a filter in my typescript code. I have a string with values like 'greyscale(73%) saturate(1400%)'. How can I apply this string to the fa-icon's filter property ...

Exploring the efficiency of different CSS selectors

I am struggling with the following code: HTML: <ul class="list"> <li class="list-item"> item 1 </li> <li class="list-item list-item_active"> Active item </li> <li class="list-item"> item 3 </li> ...

The placeholder text is not displaying with bullets in Internet Explorer. However, it is functioning correctly in Chrome

I need assistance displaying the placeholder text in IE8 as shown below: "Any relevant reference numbers, such as Direct Debits: - Name of the Branch (if applicable) - What was the original problem - Date the problem occurred " While it appears correct ...

Tips for ensuring the footer always stays at the bottom of the page

I'm having an issue with keeping the footer pinned to the bottom of the page. I haven't applied any specific styles to the footer, just placed it at the end of the content. Everything looks great until there's a page with minimal content, ca ...

Having trouble with the Slide Toggle menu closing unexpectedly?

$('span.nav-btn').click(function () { $('ul#menu').slideToggle(); }) $(window).resize(function () { if ( $(window).width() > 900) { $('ul#menu').removeAttr('style') } }); $('spa ...

Retrieving the value of a <select> element using React.useState in a Nextjs environment

Encountering an issue in Nextjs involving the useState function from React. There is a select element with multiple options. Upon selection, the useState should store the value of the selected option. const [value, setValue] = useState('') ... ...

How come my header keeps getting in the way of my hyperlink?

Why is my #menu <a> element moving to a different location every time I add my #menubarheader <h1>? Despite my knowledge of html and css, I can't seem to find a solution to this issue. Here's my code, any help would be appreciated. H ...