The justify-content-center property in Bootstrap is failing to properly align content in a row to the center

I recently created a section using Bootstrap that contains 8 buttons, with 5 in the first row and 3 in the second. However, the alignment of the content is not as I envisioned. See the current layout below:

Click here for image

Here's how I want to align the contents:

Click here for image

To achieve this, I tried adding justify-content and mx-auto properties to my row, but nothing seems to work. Below is my complete code:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">

<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

<!-- Popper JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>

<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
<style>
  .banner-cta {
    background: #23746F;
    padding: 30px;
  }
  
  .banner-cta h2,
  .banner-cta p,
  .banner-cta a {
    text-align: center;
    margin: auto;
    position: relative;
    display: block;
    color: white;
    font-family: 'Raleway', sans-serif !important;
  }
  
  .banner-cta h2,
  .banner-cta p {
    padding-bottom: 50px;
  }
  
  .banner-cta p {
    max-width: 700px;
    font-size: 1.1em;
  }
  
  #dada {
    padding-bottom: 1%;
  }
</style>


<div class="container-fluid">
  <div class="banner-cta">
    <h2 class="banner-cta-title">PARTY AT RAMOJI FILM CITY</h2>
    <div id="dada" class="row justify-content-center">
      <a href="#"><button class="btn btn-light btn-md">DAY TOURISM</button></a>
      <a href="#"><button class="btn btn-light btn-md">BIRTHDAY PARTY</button></a>
      <a href="#"><button class="btn btn-light btn-md">SAHAS</button></a>
      <a href="#"><button class="btn btn-light btn-md">CORPORATE PACKAGES</button></a>
      <a href="#"><button class="btn btn-light btn-md">VENUE BOOKINGS</button></a>
    </div>
    <div class="row">
      <a href="#"><button class="btn btn-light btn-md">SURPRISE PARTY</button></a>
      <a href="#"><button class="btn btn-light btn-md">POST WEDDING RELAX</button></a>
      <a href="#"><button class="btn btn-light btn-md">WEDDING STYLE</button></a>
    </div>

  </div>
</div>

If anyone could assist in identifying what might be wrong in my code, I would greatly appreciate it. Thank you in advance.

Answer №1

.cta-banner a {
    margin: auto;
  }

Not necessary here.

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">

<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

<!-- Popper JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>

<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
<style>
  .cta-banner {
    background: #23746F;
    padding: 30px;
  }
  
  .cta-banner h2,
  .cta-banner p,
  .cta-banner a {
    text-align: center;
    position: relative;
    display: block;
    color: white;
    margin:2px; //or more if you need
    font-family: 'Raleway', sans-serif !important;
  }
  
  .cta-banner h2,
  .cta-banner p {
    padding-bottom: 50px;
  }
  
  .cta-banner p {
    max-width: 700px;
    font-size: 1.1em;
  }
  
  #dada {
    padding-bottom: 1%;
  }
  .row{
    display:flex;
    justify-content:center
  }
</style>


<div class="container-fluid">
  <div class="cta-banner">
    <h2 class="cta-banner-title">PARTY AT RAMOJI FILM CITY</h2>
    <div id="dada" class="row justify-content-center">
      <a href="#"><button class="btn btn-light btn-md">DAY TOURISM</button></a>
      <a href="#"><button class="btn btn-light btn-md">BIRTHDAY PARTY</button></a>
      <a href="#"><button class="btn btn-light btn-md">SAHAS</button></a>
      <a href="#"><button class="btn btn-light btn-md">CORPORATE PACKAGES</button></a>
      <a href="#"><button class="btn btn-light btn-md">VENUE BOOKINGS</button></a>
    </div>
    <div class="row">
      <a href="#"><button class="btn btn-light btn-md">SURPRISE PARTY</button></a>
      <a href="#"><button class="btn btn-light btn-md">POST WEDDING RELAX</button></a>
      <a href="#"><button class="btn btn-light btn-md">WEDDING STYLE</button></a>
    </div>

  </div>
</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

Achieving tile wrapping in Bulma CSS: A simple guide

I am working on a Rails application using the Bulma CSS framework. My challenge involves displaying a long list of items in tile format, but unfortunately, they are overflowing off the screen instead of wrapping to the next line. While checking out the Bu ...

Personalized modify and remove elements on a row of the DataGrid material-ui version 5 component when hovered over

In my React Js app, I am utilizing Material UI components or MUI v5 as the UI library for my project. Within the DataGrid/DataGridPro component, I am implementing a custom edit and delete row feature. The requirement is to display edit and delete icons w ...

Positioning of the dropdown in Material UI AutoComplete menus

Is there a way to turn off autocomplete auto position? I would like the autocomplete options to always appear at the bottom. Check out this link for more information! ...

Achieving perfect alignment of an image within a Twitter Bootstrap cell when the height of the cell is uncertain

I have a bootstrap grid and I am attempting to center an image (200x100 as shown in the provided example) within a cell. <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <!DOCTYPE html> <html& ...

"Encountering a 405 error when transmitting information from an HTML file to a Python Flask server using 'GET / HTTP/1.1'

As someone who is brand new to the world of python and AJAX, I have been piecing everything together from various sources online including examples and Flask documentation. So far, I have managed to make some progress. My goal is to send latitude and longi ...

Using Font Awesome Class Aliasing

Is there a way to create an alias for a Font Awesome class like fa fa-users, and then switch between classes dynamically? I'm working on a project where I need to use Font Awesome icons, and currently I have the following code: <i class="fa fa-us ...

"The CSS attributes for right and left alignment are malfunctioning when used in conjunction with the input-group component in

Recently, I encountered a dilemma with my search input using the input-group feature in Bootstrap 4. My intention was to position this element absolutely by utilizing the left and right attributes. However, I noticed that only one of these attributes would ...

How can I use the draggable and droppable features to add <li> elements to a <ul> list?

I'm encountering a small issue with controlling the placement of my <li> elements when I implement draggable and droppable from JQuery UI. To better explain the problem, I have created a detailed fiddle: JSFiddle Why is it that the .courseBox ...

A tutorial on how to create the appearance of disabled buttons that look the same as enabled buttons through the use

My button includes a text field that is constantly disabled. I would like for the text field to appear as bright as it does when the button is enabled. After disabling the button, they both appear dimmer compared to others and the text field follows suit ...

Troubleshooting the Issue with Jquery Menu and Mouse Pointer

Recently, I've been attempting to modify the cursor behavior on a navigation menu that I stumbled upon at HTML Drive's JQuery Menu. I experimented with CSS and jQuery. In my JQuery attempt, I utilized... $("body").hover(function() { $(this).cs ...

CSS/Jade/HTML: struggling to get boxes to align properly on the same line

I'm currently working with a Jade template that looks like this: extends layout block content h2 Characters and Portraits div(id="portraitsBox") - var portraits = ["Clown-Fox", "Dragon-Bear", "Fish-Bear", "Deer-Wolf", "Salamander-Ant", "Sid ...

What is the best way to desaturate an image using CSS?

Currently on my website, I have an image displayed as follows: <img src="/Images/content/home.png" alt="" style="float: left;"> I am wondering if there is a CSS property that can be applied to desaturate this image without the need to manually edit ...

generating dynamically evolving controls within the MVC framework

I am looking to dynamically create controls in a view based on the source. For example, if the type is a text box, I want to generate a text box; if it is a check box, I want to create a check box dynamically in MVC. Below is the snippet of my current code ...

What is the best way to include Google Calendar in a div container while ensuring it is responsive?

I'm currently working on the layout of a website that features a slideshow of images at the top, followed by an embedded Google Calendar. I've encountered an issue with the responsiveness of the Google Calendar within its designated div container ...

Creating a directory using PHP's `mkdir` function with special characters results in a

My approach involves using special characters to display galleries-folders on the main page. The folders are created based on user input and I prefer not to use special characters in URLs, but rather to show content through the use of glob. $foldername= $ ...

Looking for assistance with the navbar notification icon?

My navbar notification button is causing a problem by resizing the navbar. example Below is the code snippet: .badge-notify{ background:red; position:relative; top: -20px; left: -35px; } <ul ...

Concern regarding the lack of timely response

I am experiencing an issue with the responsiveness of my template. When I test it online on various websites, everything appears to be working perfectly. However, when I try to view it on my HTC one, the responsiveness is terrible and not fully functional. ...

The issue of CSS and PHP header include file not adjusting to device size and exceeding the full width of the screen

This included code is a snippet from a header file for a website. <head> <link rel="shortcut icon" href="favicon.ico"> <meta charset="utf-8" /> <title>Test Site | Foo The Bar </title> <link rel="stylesheet" href="csss_stan ...

Passing a variable from index.html to a script in Angular

I am attempting to pass the array variable 'series' to the script in HTML. Is there a way to do this? app.component.ts import { Component } from '@angular/core'; @Component({ selector: 'my-app', templateUrl: './app ...

Template for Joomla with a white stripe running along the right side

When I resize my browser to be half the width of my screen at www.thames.ikas.sk, a white stripe appears on the right side. Why is this happening? Why aren't my html and body elements taking up the full width of the browser? This issue doesn't oc ...