position the next and previous buttons of the bootstrap carousel to be located outside of the images

I am currently using a bootstrap carousel with the following code:

<div class="slider-main-container d-block">
        <div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
            <ol class="carousel-indicators">
                <li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>

                   //@for (int i = 1; i <= Model.Sliders.Count - 1; i++)
                   //{
                        <li data-target="#carouselExampleIndicators" data-slide-to="@i"></li>
                    //}
            </ol>
            <div class="carousel-inner">
                //@foreach (var item in Model.Sliders)
                //{
                    if (_sliderCount == 1) {
                        <div class="carousel-item active">
                            <a href="@item.Link">
                                <img src="~/@item.Src" class="d-block w-100">
                            </a>
                        </div>
                    } else {
                        <div class="carousel-item">
                            <a href="@item.Link">
                                <img src="~/@item.Src" class="d-block w-100" alt="...">
                            </a>
                        </div>
                    }
                    _sliderCount++;
                //}

            </div>
            <a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
                <span class="sr-only">Previous</span>
            </a>
            <a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
                <span class="sr-only">Next</span>
            </a>
        </div>
    </div>

This code snippet generates a carousel with next and previous buttons within the images. However, I would like to have the next and previous buttons placed outside of the images like this: https://i.sstatic.net/sEHFH.jpg

Is there a way to achieve this layout?

Answer №1

To customize the spacing on both sides using CSS, you can adjust the parameters accordingly. The initial value is set to 0. For example, you can experiment with setting it to 30px as shown below and fine-tune it according to your preferences:

.carousel-control-next {
    right: -30px;
}

.carousel-control-previous {
    right: -30px;
}

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

Slanted background div that adjusts to the screen size

I'm struggling to create a slanted angle div that remains responsive as the screen size changes. Unfortunately, my current layout breaks completely when the screen gets bigger. If you'd like to take a look at what I've been working on so fa ...

Step-by-step guide on positioning a div below another div and centering both elements horizontally

Trying to center the "input" div below the "InputBelow" div using "flex-direction: column" is causing issues with "justify-content; center." The goal is to center the main "border" div in the middle of the screen and align the other elements inside it. ...

Creating a visually stunning image grid akin to the meticulously designed layouts found

Forgive my lack of knowledge, but I'm curious about how to create an image or text grid similar to Tumblr using HTML and CSS. I'm looking to achieve a layout like this: ...

Place the social media division at the center of the webpage

I've been struggling to center the social media icons on my website, but haven't had any luck. Here's the code I've been working with: https://jsfiddle.net/2ahgL130/1/ CSS: .table1{ margin:0; padding:0; min-width:100% } ...

Designing a layout for a chat application that is structured from the bottom up

I'm currently in the process of designing a web application for a chat platform. I have access to an API that provides a list of messages: chatsite.com/api/thread/1/messages/ [ { "id": 2, "sender": { "id": 2, ...

Obtaining values from a table using jQuery

The code snippet below is used to create a table: <table class="table table-bordered table-striped" id="assignedvs"> <thead> <tr> <th>VlId</th> <th>Name</th> ...

CSS failing to acknowledge specified div background

After successfully configuring the featured-top and footer elements in my CSS, I encountered an issue with a persistent white line appearing between them. Despite inspecting the elements in Google Chrome, I couldn't identify the source of this problem ...

Tips for accurately placing a border on an active link using active_link_to in Rails 4

Currently, I am utilizing active_link_to to monitor changes in the state of my navigation bar links. Upon adding styling to the active state, the appearance resembles the image depicted below. My aim is to shift the border of the active state towards the t ...

Tips for concealing the "maxlength" attribute in HTML

Here is the code snippet I currently use on a signup and login form to restrict users from entering more than a specified number of characters: $( "#limit1" ).attr('maxlength','11').on('input', function() { if ($(this).val(). ...

The PHP script is exhausting memory resources and triggering a fatal error

I encountered the following error message: Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 528384 bytes) in /home/u234536193/domains/monetizingonline.com/public_html/wp-includes/wp-db.php on line 2024 The problematic cod ...

Adjusting button alignment when resizing the browser

Is there a method to relocate buttons using Bootstrap 5 in HTML or CSS when the browser is resized? For instance, if the button is centered on a full-screen browser, but I want it at the bottom when resized. Is this achievable? ...

Tips on adjusting the body or HTML to fill the entire page

Currently, I am designing the homepage using the bootstrap Cover page template. The images displayed are just placeholders. While the site functions perfectly on desktop screens, resizing it to smaller sizes causes the grid layout to collapse into a single ...

Steps for developing a floating image transition using CSS and React

Looking to achieve a floating image transition using CSS and React, similar to the Divi theme header images. Check out the example below: enter image description here For more information, visit: ...

Changing the color of the active link in the navigation bar when the href is empty

I need to change the active link color after it has been clicked. For example, when I click on the "START" link, I want the text to appear in a different color. Currently, my code only works when I have "#" links, such as when I click on "O HODOWLI", the " ...

The comparison between Bootstrap 4 collapsible and expanded menus

Forgive me if this question has already been asked (I'm still new to all of this and learning, finding the answer in search is challenging). I'm attempting to create a collapsible navbar that, when expanded, displays items separated by a "|" sym ...

Activating Email Subscription Form by Clicking on Icon Image

I'm attempting to include an email submission form box that appears when users click on a small envelope icon located at the top right corner of my page. However, I've encountered some difficulty as it either shows up in the midst of other icons ...

How to instantly modify the background color of a collapsed Bootstrap navbar

I managed to successfully change the background color of the collapsed menu bar in my project using bootstrap-vue in Nuxt. However, the issue I am facing is that the color only appears when the collapsed menu is fully opened. I made the styling change to t ...

Exploring Angular 4: A deep dive into routing and ensuring responsiveness

I set up an ubuntu server on AWS and most things are running smoothly, but there are a couple of issues that have me stumped. When visiting my web app, you can only interact with the buttons in the menu. Trying to access a link like 'mypage/items&ap ...

The on-screen keyboard using JQuery and CSS is not working properly on an HTML redesign

UPDATE - Check out the modified version here: https://codepen.io/anon/pen/wZQjQy Here is the original for reference: https://codepen.io/anon/pen/YMRLBN (had to utilize CodePen, as simply adding a snippet here doesn't link the CSS) I essentially copie ...

Troubleshooting problems with Bootstrap cards on mobile devices

I've encountered an issue on small devices with the Bootstrap card. I'm using a hover effect to slide up the content, but on small devices, the content is cutting off the image. I'm not sure how to position the content directly after the ima ...