The divs contained are misaligned and not properly centered on the page

My container div contains 6 inner divs, but they are not properly centered on the page.

Although the divs are equally spaced apart, they seem to be shifted to the left. I tried using 'justify-content: center' without success, and I suspect it might be due to the 'float: left' property applied to the entire section?

Mostly inline CSS is used, with some additional CSS, so I apologize for any confusion caused by the mix.

Here's an image showing the slight left alignment:

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

HTML:

    <div>
  <section style="float: left;" id="quality__info">
    <span style="font-size: 3rem; font-weight: 700;"> Clear and comfortable </span>
    <p style="font-size: 1.7rem; opacity: 1; margin-bottom: 10px; padding-left: 30px; padding-right: 30px;"> We remove the need to empty leaked water or clean fogged up glass thanks to the full-face design. </p>
    <div class="col-lg-11 col-12 wow fadeInUp">
      <div style="display: flex; -ms-flex-wrap: wrap; flex-wrap: wrap; margin-right: -15px; margin-left: -15px;" class=row>


        <div class="col-lg-4 col-md-6 col-12 quality__item">
          <div class="descriptionImageAndText">
            <img class="descriptionImage" style="width: 300px;" src="{{ 'cameraBlue.png' | asset_url }}" alt="Quick Connection" width="100%">

            <span class="titleDescription"> CAMERA MOUNTING </span>
            <p class="pDescription"> All gopro's and similar mountable cameras are compatible with the mask and can be secured on safely with the tools provided. </p>
          </div>
          <hr class="hrMobile" size="3" style="margin-top: 5px;">
        </div>

        <div class="col-lg-4 col-md-6 col-12 quality__item">
          <div class="descriptionImageAndText">
            <img class="descriptionImage" style="width: 300px;" src="{{ 'Anti-Fog.png' | asset_url }}" alt="Quick Connection" width="100%">

            <span class="titleDescription"> ANTI-FOG </span>
            <p class="pDescription"> All air is circulated around the masks outer layer and away from the visual screen.</p>
          </div>
          <hr class="hrMobile" size="3" style="margin-top: 5px;">
        </div>

        <div class="col-lg-4 col-md-6 col-12 quality__item">
          <div class="descriptionImageAndText">
            <img class="descriptionImage" style="width: 300px;" src="{{ 'anotherGood.png' | asset_url }}" alt="Quick Connection" width="100%">

            <span class="titleDescription"> EASY BREATHING </span>
            <p class="pDescription"> The seacaster X1 controls the airflow by circulating it around the masks outer tubes, with a separate intake valve for easier breathing.</p>
          </div>
          <hr class="hrMobile" size="3" style="margin-top: 5px;">
        </div>

        <div class="col-lg-4 col-md-6 col-12 quality__item">
          <div class="descriptionImageAndText">
            <img class="descriptionImage" style="width: 300px;" src="{{ 'goodBlack.png' | asset_url }}" alt="Quick Connection" width="100%">

            <span class="titleDescription"> ANTI-LEAK </span>
            <p class="pDescription"> The Seacaster X1 uses a double-rim to seal against incoming water, it also provides comfortability with material designed to not irritate.</p>
          </div>
          <hr class="hrMobile" size="3" style="margin-top: 5px;">

        </div>

        <div class="col-lg-4 col-md-6 col-12 quality__item">
          <div class="descriptionImageAndText">
            <img class="descriptionImage" style="width: 300px;" src="{{ 'goodPink.png' | asset_url }}" alt="Quick Connection" width="100%">

            <span class="titleDescription"> DURABILITY </span>
            <p class="pDescription"> The mask is designed to withstand the pressures of being in the sea and being dropped on rocks on the beach. </p>
          </div>
          <hr class="hrMobile" size="3" style="margin-top: 5px;">
        </div>

        <div class="col-lg-4 col-md-6 col-12 quality__item">
          <div class="descriptionImageAndText">
            <img class="descriptionImage" style="width: 300px;" src="{{ 'Full_Vision.png' | asset_url }}" alt="Quick Connection" width="100%">

            <span class="titleDescription"> WIDE VISION </span>
            <p class="pDescription"> The wide, flat visual screen with the separated, internal nostril creates a full 180 degree view. </p>
          </div>

          <hr class="hrMobile" size="3" style="margin-top: 5px;">

        </div>

      </div>
    </div>


  </section>
</div>

CSS:

    #quality__info {
    padding-top: 25px;
    padding-bottom: 45px;
    text-align: center;
    background-color: white;
}

.quality__text {
    display: flex;
    text-align: left;
    -webkit-box-align: start;
    -ms-flex-align: start;
    align-items: flex-start;

}

@media screen and (max-width: 768px) {
  .quality__item {
    max-width: 80%;
    margin-left: auto;
    margin-right: auto;
 }
}


@media (min-width: 992px) {
.container {
    max-width: 960px;
 }
}

.titleDescription {
    font-size: 1.9rem;
    font-weight: 600;
    padding: 10px;
    display: block;

}

.pDescription {
    padding-top: 3px;
    padding-bottom: 15px;
}

.descriptionImage {
  padding-bottom: 10px;
}

.descriptionImageAndText {
    vertical-align: top;
    display: inline-block;
    text-align: center;
}

Answer №1

Revise the code by deleting the col-lg-11 class:

#quality__info {
    padding-top: 25px;
    padding-bottom: 45px;
    text-align: center;
    background-color: white;
}

.quality__text {
    display: flex;
    text-align: left;
    -webkit-box-align: start;
    -ms-flex-align: start;
    align-items: flex-start;

}

@media screen and (max-width: 768px) {
  .quality__item {
    max-width: 80%;
    margin-left: auto;
    margin-right: auto;
 }
}


@media (min-width: 992px) {
.container {
    max-width: 960px;
 }
}

.titleDescription {
    font-size: 1.9rem;
    font-weight: 600;
    padding: 10px;
    display: block;

}

.pDescription {
    padding-top: 3px;
    padding-bottom: 15px;
}

.descriptionImage {
  padding-bottom: 10px;
}

.descriptionImageAndText {
    vertical-align: top;
    display: inline-block;
    text-align: center;
}
<div>
  <section style="float: left;" id="quality__info">
    <span style="font-size: 3rem; font-weight: 700;"> Clear and comfortable </span>
    <p style="font-size: 1.7rem; opacity: 1; margin-bottom: 10px; padding-left: 30px; padding-right: 30px;"> We remove the need to empty leaked water or clean fogged up glass thanks to the full-face design. </p>
    <div class="col-12 wow fadeInUp">
      <div style="display: flex; -ms-flex-wrap: wrap; flex-wrap: wrap; margin-right: -15px; margin-left: -15px;" class=row>


        <div class="col-12 col-md-6 col-12 quality__item">
          <div class="descriptionImageAndText">
            <img class="descriptionImage" style="width: 300px;" src="{{ 'cameraBlue.png' | asset_url }}" alt="Quick Connection" width="100%">

            <span class="titleDescription"> CAMERA MOUNTING </span>
            <p class="pDescription"> All gopro's and similar mountable cameras are compatible with the mask and can be secured on safely with the tools provided. </p>
          </div>
          <hr class="hrMobile" size="3" style="margin-top: 5px;">
        </div>

        <div class="col-12 col-md-6 col-12 quality__item">
          <div class="descriptionImageAndText">
            <img class="descriptionImage" style="width: 300px;" src="{{ 'Anti-Fog.png' | asset_url }}" alt="Quick Connection" width="100%">

            <span class="titleDescription"> ANTI-FOG </span>
            <p class="pDescription"> All air is circulated around the masks outer layer and away from the visual screen.</p>
          </div>
          <hr class="hrMobile" size="3" style="margin-top: 5px;">
        </div>

        <div class="col-12 col-md-6 col-12 quality__item">
          <div class="descriptionImageAndText">
            <img class="descriptionImage" style="width: 300px;" src="{{ 'anotherGood.png' | asset_url }}" alt="Quick Connection" width="100%">

            <span class="titleDescription"> EASY BREATHING </span>
            <p class="pDescription"> The seacaster X1 controls the airflow by circulating it around the masks outer tubes, with a separate intake valve for easier breathing.</p>
          </div>
          <hr class="hrMobile" size="3" style="margin-top: 5px;">
        </div>

        <div class="col-12 col-md-6 col-12 quality__item">
          <div class="descriptionImageAndText">
            <img class="descriptionImage" style="width: 300px;" src="{{ 'goodBlack.png' | asset_url }}" alt="Quick Connection" width="100%">

            <span class="titleDescription"> ANTI-LEAK </span>
            <p class="pDescription"> The Seacaster X1 uses a double-rim to seal against incoming water, it also provides comfortability with material designed to not irritate.</p>
          </div>
          <hr class="hrMobile" size="3" style="margin-top: 5px;">

        </div>

        <div class="col-12 col-md-6 col-12 quality__item">
          <div class="descriptionImageAndText">
            <img class="descriptionImage" style="width: 300px;" src="{{ 'goodPink.png' | asset_url }}" alt="Quick Connection" width="100%">

            <span class="titleDescription"> DURABILITY </span>
            <p class="pDescription"> The mask is designed to withstand the pressures of being in the sea and being dropped on rocks on the beach. </p>
          </div>
          <hr class="hrMobile" size="3" style="margin-top: 5px;">
        </div>

        <div class="col-12 col-md-6 col-12 quality__item">
          <div class="descriptionImageAndText">
            <img class="descriptionImage" style="width: 300px;" src="{{ 'Full_Vision.png' | asset_url }}" alt="Quick Connection" width="100%">

            <span class="titleDescription"> WIDE VISION </span>
            <p class="pDescription"> The wide, flat visual screen with the separated, internal nostril creates a full 180 degree view. </p>
          </div>

          <hr class="hrMobile" size="3" style="margin-top: 5px;">

        </div>

      </div>
    </div>


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

Divide a page into two equal halves

I have been working on the code below. The circular icons function as navigation buttons. The collapsible list is located in the second div. My goal is to align the list to the right side of the navigation buttons. Despite trying to wrap the divs and us ...

Why doesn't the div click event trigger when the mouse hovers over an iframe?

My dilemma involves a div element with a click event. When the div is positioned over an iframe area (closer to the user than the iframe), the click event fails to trigger. However, if the div is located elsewhere and not above the iframe, the click event ...

What is the process for incorporating a Bootstrap link into a specific ReactJS file?

In my current project using React JS, I found the need to incorporate Bootstrap in certain pages. To do this, I initially placed the following code snippet in the Public folder within index.html: <link rel="stylesheet" href="https://netdna.bootstrapc ...

Tips for identifying the correct selectedIndex with multiple select elements present on one page

How can I maintain the correct selectedIndex of an HTMLSelectElement while having multiple select elements in a loop without any IDs? I am dynamically loading forms on a webpage, each containing a select element with a list of priorities. Each priority is ...

Angular - Acquire reference to the <audio> element

Is there a way to access the methods of an audio tag within my component in order to implement play and pause functions based on click events? The current method I tried does not allow me to access the play() function. How can I correctly approach this? ...

Establish height and width parameters for creating a dynamic and adaptable bar chart with recharts

I am currently facing an issue with recharts while trying to implement a BarChart. The setting width={600} and height={300} is causing the Barchart to be fixed in size, rather than responsive. How can I make the BarChart responsive? I attempted using per ...

What is the best way to position a popup div in CSS?

Currently, I am in the process of developing a website that displays DVD details when hovering over an image, similar to what is shown in picture 1. However, I've encountered an issue where the content gets cut off for DVDs located on the right side o ...

The button on my page refuses to align in the center, and I'm at a loss as

Struggling to center a button within my div, despite having all other content centered. Here is my code: .middle { width: 100%; height: auto; text-align: center; position: relative; ...

How can we develop an AJAX chat with enhanced scrolling capabilities?

Could someone provide me with some examples on how to achieve this task? I already have some HTML code: <div id="chatDisplay"> </div> <input type="text" id="message" /><input type="button" id="send" value="Send" /> Next, I have so ...

Designing table rows to resemble full-width cards

Looking for a way to transform the rows of a table into full-width cards while maintaining the row layout? Here's what I have tried so far: tbody>tr { display: block; padding: 1rem 0.5rem 1rem 0.5rem; margin: 1.5rem; border: 1px solid rgba( ...

Arranging elements on top of a fixed element using JavaScript and CSS

Currently, I am implementing Javascript code that adds a div to the body of pages. The purpose of this div is to always stay at the top of the document or window, regardless of the page's design and content. Everything was functioning correctly until ...

Add elements to a ul element using JavaScript and make the changes permanent

Managing a dashboard website with multiple div elements can be quite tedious, especially when daily updates are required. Manually editing the HTML code is inefficient and time-consuming. Each div contains a ul element where new li items need to be added ...

The iframe content is not updating despite using jQuery

On this site , the following code is present: <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <iframe style="position: absolute; top: 0; left: 0; height: 100%; width: 100%" src="blank.html"></iframe ...

HTML View of JSON Object Hierarchy

Hello, I have been trying various methods but am struggling to figure out how to display the following JSON object as a tree HTML view with ul li items using JavaScript. Can anyone help me with this? [ { "CategoriesModelId": 7, "Name": "Parent ...

The Hidden Div containing NicEdit is now shrunk down to a smaller size

Attempting to integrate the NicEdit editor for a hidden textarea stored within a div has presented some challenges. The goal is for the targeted textarea's parent div to be revealed upon the user clicking a button, with the textarea's width set t ...

Integration of a QR code scanner on a WordPress website page

I'm in the process of setting up a QR code scanner on my Wordpress site or within a popup. The goal is for users to be able to scan a QR code when they visit the page/popup link. Specifically, the QR code will represent a WooCommerce product URL, and ...

The conditional rendering logic in the ng-if directive does not seem to be synchronizing

Currently, I am delving into AngularJS and working on a basic application to gain familiarity with it. Within my app, there are four tabs: List, Create, Update, and Delete. However, my goal is to only display the Update and Delete tabs when I press the b ...

The form will only display results after the "Submit" button is clicked twice

Recently, I built a flask website where the form and results are displayed on the same page. However, there seems to be an issue that arises upon clicking the 'submit' button for the first time after running 'flask run'. The error messa ...

Feature exclusively displays malfunctioning image URLs for the web browser

Hello everyone! I've been diving into learning JavaScript and recently attempted to create a function that randomly selects an image from an array and displays it on the browser. Unfortunately, despite my efforts, all I see are broken link images. Her ...

Emphasize cells and headers when a cell's value deviates from its initial value

I implemented cell editing in my primeng table. Here is the code: <div class="card"> <p-table [value]="products" dataKey="id" [tableStyle]="{ 'min-width': '50rem' }"> <n ...