How can I turn off the width for carousel control buttons in Bootstrap?

I am encountering a problem with the carousel control buttons in Bootstrap, as shown in this image: https://i.sstatic.net/olfKU.png

However, when I disable the width: 15% property in the devTools on Chrome, the issue resolves itself: https://i.sstatic.net/LgZeK.png https://i.sstatic.net/yhcEg.png

I attempted to set width: auto, but I couldn't find a way to address it in my code below. Is there a method to turn off the width of the carousel-control-prev and carousel-control-next:

.carousel {
  display: flex;
  .carousel-inner {
    .carousel-item {
      .testimony {
        display: flex;
        img {
          width: 150px;
          height: 150px;
          object-fit: cover;
          aspect-ratio: 1;
          border-radius: 75px;
          margin-right: 27px;
        }
        .name {
          font-weight: bold;
          display: block;
        }
      }
    }
  }
  .carousel-control-prev,
  .carousel-control-next {
    position: relative;
    opacity: 1;
  }
  .carousel-control-prev-icon {
    width: 50px;
    height: 50px;
    mask-image: url("../../public/img/carousel-arrow.svg");
    background-color: $red;
    transition: background-color 100ms ease-in, opacity 100ms ease-in;
    &:hover {
      background-color: #DF011F;
      opacity: 0.8;
    }
  }
  .carousel-control-next-icon {
    width: 50px;
    height: 50px;
    mask-image: url("../../public/img/carousel-arrow.svg");
    transform: rotate(180deg);
    background-color: $red;
    transition: background-color 100ms ease-in, opacity 100ms ease-in;
    &:hover {
      background-color: #DF011F;
      opacity: 0.8;
    }
  }
  @include media-breakpoint-down(md) {
    .carousel-control-prev-icon {
      transform: scale(0.75);
    }
    .carousel-control-next-icon {
      transform: rotate(180deg) scale(0.75);
    }
  }
}
<div id="carousel" class="carousel slide" data-bs-ride="carousel">
  <button class="carousel-control-prev" type="button" data-bs-target="#carousel" data-bs-slide="prev">
    <span class="carousel-control-prev-icon" aria-hidden="true"></span>
    <span class="visually-hidden">Previous</span>
  </button>
  <div class="carousel-inner">
    <div class="carousel-item active">
      <div class="testimony">
        <img src="{{ asset('img/talents/sylvie.jpg') }}" alt="john doe" class="d-none d-lg-block">
        <div>
          <p>test</p>
          <span class="name">John Doe</span>
          <span class="job">Chief</span>
        </div>
      </div>
    </div>
  </div>
  <button class="carousel-control-next" type="button" data-bs-target="#carousel" data-bs-slide="next">
    <span class="carousel-control-next-icon" aria-hidden="true"></span>
    <span class="visually-hidden">Next</span>
  </button>
</div>

Answer №1

If you want to customize bootstrap default styles, just include a !important at the end of your CSS code.

For example:

.carousel-control-next, .carousel-control-prev {
    width: auto !important;
}

Answer №2

The issue was resolved by the following action:

.carousel-control-prev, .carousel-control-next { width: auto !important; }

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

The hexadecimal code for the textured background color of an iOS Scroll View in CSS

Can someone share the specific CSS color code with me? I would like to apply this same color to my website. Appreciate it! ...

Achieving a half-faded effect for an image using CSS

https://i.sstatic.net/4SMsM.jpg In the image provided, there is a need to smoothly fade half of it without relying on opacity for the effect. The current method does not achieve the desired smooth fading effect. ...

Animate elements using fixed position without unexpected jumps

Trying to create an animation that expands a box to full screen. However, when I set the position to fixed before the animation begins, the box quickly moves up to the upper left corner. Is there a way to make it expand from its original location instead? ...

What is the best way to ensure the dropdown box in a Bootstrap navbar automatically adjusts its width to fit within the

When I click on the dropdown menu, the box extends beyond the width of the page and a horizontal scroll appears. How can I make the dropdown box automatically adjust its position if it reaches the edge of the page without needing a scroll (as shown in the ...

Creating a sleek appearance for Bootstrap input within the selectize.js component by mimicking the input-sm

I am currently working with a selectize component that appears like this: https://i.sstatic.net/z2aTw.png My objective is to adjust the appearance of the search input to make it smaller by changing its class from the standard bootstrap input to input-sm. ...

Spin the context of every element using JavaScript

const pic = new Image(); pic.src = 'assets/img/image.png'; for (let i = 0; i < this.bombs.length; i++) { const bomb = this.bombs[i]; ctx.drawImage(pic, bomb.x - 2, bomb.y - 2, 15, 8); } I have an image falling from the top of my canvas g ...

PHP-generated HTML often contains unnecessary and excessive indentation

I'm trying to adjust the indentation of my HTML generated by PHP, but I'm facing issues removing some unwanted indentations. Take a look at this snippet from the HTML source: <table id="structure"> <tr> <td id="navigation"> ...

To create space between the input field and button, utilize the input-group class for

Is there a way to insert a space between the input field and the button while using input-group in Bootstrap 3? Check out this jsFiddle for more information. <div class="container"> <div class="row"> <div class="col-md-12"> ...

Choosing an element in JQuery based on the value of its style property

I have three divs with the same class but different styles. I need to select only the third one using JQuery. <div class="ui-dialog ui-widget ui-widget-content ui-corner-all ui-draggable" tabindex="-1" role="dialog" aria-labelledby="ui-dialog-title-div ...

The PHP code embedded within the HTML document and triggered by an AJAX request failed to

Here is an example of my ajax call: function insertModal(link) { $.ajax({ url: link, cache: false, dataType: "text", success: function(data) { $("#modalInput").html(data); }, error: function (request, status, error) { ...

Question about CSS sprites: How can I set the horizontal background position properly

I stumbled upon this tutorial on creating sprites here. To see the finished result of the CSS sprites, click here. Below is the complete CSS code: #skyline { width: 400px; height: 200px; background: url(test-3.jpg); margin: 10px auto; padding: 0; pos ...

JQuery GET brings back unnecessary HTML content

Currently utilizing a PHP cart class and implementing some jQuery to dynamically update a div when users add products. The issue I'm encountering is that upon adding a product, the list of products on the HTML page gets duplicated (see screenshot) ev ...

Using jQuery to create a drop-down menu

I currently have a table filled with data. Whenever a user clicks on a cell within a specific column, I would like it to transform into a select dropdown menu. This dropdown menu will allow the user to choose a category for that particular row. The selecte ...

Exploration of features through leaflet interaction

Attempting to plot bus routes on a map using leaflet with geojson for coordinates. Facing issues with making the bus line bold when clicked, and reverting the style of previously clicked features back to default. Current Progress function $onEachFeature( ...

Instructions for creating a Google Maps overlay that hovers above the zoom bar

Let me share my workaround for creating an overlay and dealing with z-index issues when using Google Maps API. The problem arises when dragging the map and the overlay ends up behind control elements like the zoom bar. No matter how much I adjust the z-ind ...

"Implemented a user-friendly header and footer that stick to the top and

My goal is to create a fixed header and footer, allowing the main content to scroll underneath while keeping the right navigation in place. To achieve this effect, I've been experimenting with different solutions. One of my attempts can be viewed her ...

What is the reason why the show() function in JQuery only applies to one specific element, rather than all elements selected with the same selector?

JSFiddle. This example code features a nested <table> within another <table>. The main issue concerns the click listener for the #add button. Specifically, the final if/else statement in the function. When you execute this code and click the ...

Sleek and adaptable side spacing feature

While utilizing the Neat framework, I found that the column's gutter adjusts itself based on the window size, which is a common feature of grid frameworks. In my current project, I want to utilize the gutter-width ($gutter) as padding for certain elem ...

Creating a personalized LinkedIn share button through POST requests: here's how

I am interested in using my own image for the LinkedIn share button. After referencing a previous post on this topic: How to make a custom LinkedIn share button It was mentioned that: In order to create a custom Share button for LinkedIn, POST calls need ...

<div class="firstHeaderClass"> What exactly is this?

Struggling to eliminate a recurring header across all my webpages for customization, I've hit a roadblock in identifying the source of this repeating header. Upon stumbling upon this code snippet in the header section, my efforts to decipher its ...