Align a card in the center of a carousel using Bootstrap

I'm looking to include a card within a carousel, but I'm struggling with getting the card element centered inside the carousel. Here's my current code:

<div class="container">
    <div class="row">
        <div class="col-sm-12">

            <div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
                <ol class="carousel-indicators">
                    <li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
                    <li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
                    <li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
                </ol>
                <div class="carousel-inner text-center">
                    <div class="carousel-item active row justify-content-center">
                        <div class="col-md-6 d-flex justify-content-center">
                            <div class="card">
                                <div class="card-body">
                                    <h5 class="card-title">ID</h5>
                                    <input type="number" class="form-control" placeholder="0000" aria-label="Chain ID"
                                        aria-describedby="basic-addon1">
                                    <a routerLink="eth" class="btn btn-primary">Get Started</a>
                                </div>
                            </div>
                        </div>

                    </div>
                    <div class="carousel-item">
                        <p>2</p>
                    </div>
                    <div class="carousel-item">
                        <p>3</p>
                    </div>
                </div>
                <a class="carousel-control-prev" href="#carouselExampleIndicators" 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="#carouselExampleIndicators" 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>

Current output screenshot can be seen here. How can I modify my code to center the card inside the carousel?

Other

Answer №1

Revise your HTML Structure

<div class="carousel-item active">
                        <div class="row d-flex justify-content-center"> <!-- Include Class & Exclude Class -->
                          <div class="col-md-6"><!-- Insert Div Here -->
                            <div class="card">
                                <div class="card-body">
                                    <h5 class="card-title">Unique ID</h5>
                                    <input type="number" class="form-control" placeholder="0000" aria-label="Chain ID"
                                        aria-describedby="basic-addon1">
                                    <a routerLink="eth" class="btn btn-primary">Begin Now</a>
                                    </div> <!-- Add closing div here -->
                                </div>
                            </div>
                        </div>

                </div>

https://jsfiddle.net/lalji1051/jfaqvw7c/

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

A method to extract the value of an array by referencing the primary key value

To create a unique name for my extra text field, I am utilizing the primary key of the room_extras table. For example: <tr> <td><?php echo $extrasInfo['description'] ?></td> <td> <input type="tex ...

AngularJS version is a software update for the Angular

I recently started learning AngularJs and have been following the Oreilly AngularJS book. I was able to successfully run this code with Angular version 1.0.8, but it doesn't work with newer versions of Angular. Can someone tell me why? <!DOCTYPE h ...

Is there a method to enable an anchor tag to be clickable when it's nested within a router-link?

Here's the code snippet for a component I'm working on: <template> <div id="news" class="news page"> <router-link class="news-card" :to="{ name: 'news-article'}"> < ...

Restricting CSS Background Image Width to 960 Pixels

My CSS style is causing my background image to span across the whole screen instead of repeating within the 960px width of the body. body { width:960px; margin: 10px auto 10px auto; background-image:url(logo.png),url(backgroundimage.jpg); ...

Distinguish using section class in Selenium

Currently grappling with a Python selenium issue, I need to extract and print an email address in my code: [email protected] Just looking for a hint... HTML: <section tabindex="-1" class="pv-profile-section pv-contact-info artdeco- ...

Meta tags are causing issues with HTML5 validation on the website

Striving to enhance the HTML validity of my website, I encountered several errors in the meta tags that are marked as invalid. Unfortunately, I am unsure how to modify them to rectify these errors. <meta http-equiv="X-UA-Compatible" content="IE=edge,ch ...

Tips for correctly importing Bootstrap 4 sass into your create-react-app project

Before, I included bootstrap in style.less like this (without using a JS framework): @import "bootstrap/less/bootstrap.less"; @import "variables.less"; @import "mixins.less"; @import "main.less"; ... Now with the use of create-react-app, I organize each ...

Creating a dropdown menu in AngularJS using the ng-repeat directive

I have recently started working with AngularJS. I am trying to create three tickets using ng-repeat, each containing a dropdown list to select the number of tickets. However, I am facing an issue where the selected number is not displaying in the span. Can ...

Issue with jQuery functionality when page is loaded through AJAX request

My index page currently has jQuery and a js file for a slider plugin loaded. I am using an on click event to load an external page using .load. Here is the code snippet: //jQuery loaded from Google CDN here (in head) jQuery( document ).ready(function() { ...

Adding the <br> tag in a Bootstrap modal: a simple guide

Hi everyone! I am currently working with a bootstrap modal to create a login functionality within the modal itself. There is a data validation function in place. However, when an error occurs, the word 'br' displays directly in the HTML instead ...

Unable to place an absolutely positioned Div within relative parent containers

After applying the id "enterGame" with position: absolute, I noticed that the div disappears. Even when I tried adding position: relative to the body or html tag, the div remained invisible. The relevant code snippet is as follows: html { height: 10 ...

Why does Laravel DatePicker consistently default to showing the previous month instead of the selected month?

I've hit a roadblock trying to pinpoint the source of this error in the Tailwind UI Datepicker. Whenever I choose 09-08-2021 on the visual Datepicker, the value ends up saving as 09-07-2021. I've researched similar cases where the month value re ...

Tips for designing the microphone appearance on the Google Chrome speech input interface

Google Chrome features an input control for speech recognition. If you want to know how to use it, check out this link. I'm looking to enlarge the microphone icon and possibly use a customized image for it. Increasing the width and height of the inp ...

What are the best techniques for creating a responsive UI design that adapts to all screen widths?

I created a UI by following some tutorials, but I'm facing an issue with responsiveness. When I resize the window, the UI doesn't look good or adjust properly. Here is the link to my fiddle: http://jsfiddle.net/X8HV9/1/show/ I am encountering tw ...

Exploring MongoDB through User Interface Requests

As part of a project to develop a minimalist browser-based GUI for MongoDB, an interesting question has arisen. How can we accurately display the current state of the database and ensure it is continuously updated? Specifically, what methods can be utiliz ...

Switch out the checkbox for a span for a different approach

Working with Angular 9 reactive forms, I am currently using the following form setup: <form [formGroup]="form" (ngSubmit)="onSubmit()"> <label for="active">Active</label> <input id="active" type="checkbox" formCo ...

Ui Bootstrap (angularjs) sidebar is not functioning properly

I am encountering an issue with a sidenav that I am in the process of creating for one of my projects. The goal is to develop a side menu that shifts the content to the right when opened and returns it to the left when closed, essentially functioning as a ...

Switch up the CSS variable within an embedded iframe

I'm in a predicament with a specific issue. I am currently utilizing Angular to incorporate an Iframe. Let's imagine the angular app as A and the Iframe as B. B is being loaded within A. Within B, I have utilized CSS variables to define colors. I ...

different ways to dynamically increase CSS ID in PHP

Is there a way to dynamically increment my CSS ID using PHP? foreach ($query_cat->result() as $row_cat) { $row_cat_id = $row_cat->id; echo '<div class="product-wrapper">'; echo '<div id="product-header' . $r ...

How can you horizontally align a collection of elements using CSS?

I'm struggling to align a paragraph element with a group of button elements using jQuery and CSS. This is my issue: My goal is to have all these elements on the same horizontal line at the top of the screen to make the most of the pixel real-estate. ...