Issue with Bootstrap 4: why isn't the second row taking up the full width

The body's structure is depicted in the following code:

<main role="main" class="container">
        <div class="starter-template">
          <div class="row text-center">
            <div class="col-md-4">
              <div class="align-middle">
                <h1 class="display-5">Headline 1</h1>
                <p>Lorem Ipsum. </p>
              </div>
            </div>
            <div class="col-md-5 my-2"><span>Some text in the other column</span></div>
          </div>
          <div class="row text-center">
            <div class="row">
              <h2>Headline 2</h2>
            </div>
            <div class="row full-width">
              <div class="col-md-4">
                <div class="row">
                  <h4 class="text-center">Box 1</h4>
                </div>
                <div class="row"><span>abc</span><span>def</span></div>
              </div>
              <div class="col-md-4">
                <div class="row">
                  <h4 class="text-center">Box 2</h4>
                </div>
                <div class="row"><span>abc</span><span>def</span></div>
              </div>
              <div class="col-md-4">
                <div class="row">
                  <h4 class="text-center">Box 3</h4>
                </div>
                <div class="row"><span>abc</span><span>def</span></div>
              </div>
            </div>
          </div>
        </div>
      </main>

Examining the structure, it is observed that the first row with two columns displays correctly, while the second row does not span the full width like the first row. The challenge lies with keeping Headline 2 centered and ensuring the full width of the row.

This is the current output: https://i.sstatic.net/RcHLR.png

To address this issue, an attempt was made to set the width to 100%, but it did not yield the desired result. Further adjustments may be needed to achieve the desired layout.

Answer №1

In the midst of your nested rows, there is a row within a row designated for Headline 2. Instead of the nested row, the example below opts for a full-width column col-md-12

<main role="main" class="container">
  <div class="starter-template">
    <div class="row text-center">
      <div class="col-md-4">
        <div class="align-middle">
          <h1 class="display-5">Headline 1</h1>
          <p>Lorem Ipsum. </p>
        </div>
      </div>
      <div class="col-md-5 my-2"><span>Some text in the other column</span></div>
    </div>
    <div class="row text-center">
      <div class="col-md-12">
        <h2>Headline 2</h2>
      </div>
      <div class="col-md-4">
        <div class="row">
          <h4 class="text-center">Box 1</h4>
        </div>
        <div class="row"><span>abc</span><span>def</span></div>
      </div>
      <div class="col-md-4">
        <div class="row">
          <h4 class="text-center">Box 2</h4>
        </div>
        <div class="row"><span>abc</span><span>def</span></div>
      </div>
      <div class="col-md-4">
        <div class="row">
          <h4 class="text-center">Box 3</h4>
        </div>
        <div class="row"><span>abc</span><span>def</span></div>
      </div>
    </div>
  </div>
</main>

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

Tips for integrating Sass into a React application with bundle.js and bundle.css

I'm currently working on a React project that uses bundle.js/bundle.css, which are linked in the index.html like this: <script src="/bundle.js"></script> <link rel="stylesheet" href="/bundle.css" /> Ini ...

Challenges with custom select boxes in Firefox

Is anyone else experiencing issues with a custom select box in Firefox? It seems like the problem might be related to the code snippet below: $(".custom-select-trigger").on("click", function() { $('html').one('click',function() { ...

Arranging flex items in a row next to another flexbox container with aligned direction

Is it possible to mix flex directions column and row within the same div? Let's take a look at an example: https://i.sstatic.net/Gumu5.png .container { display: flex; } .container .left { display: flex; align-items: center; flex: 1; } .co ...

CSS: Select the final child within a parent element depending on the specific class assigned to the child element

Is there a way to change the text color of 5 to red? I've tried some solutions, but nothing seems to work. Any ideas on how to fix this issue? Please Note: This example is just a simplified version of the actual problem, so the structure and quantit ...

Profile picture placeholder with conditional logic

After extensively searching online, I was unable to find a solution on how to add a default profile picture. Here is the code snippet I used for uploading an image chosen by the user: <td><img class="image" src="image/<?php echo $contact[&apos ...

Challenges with CSS in Google Chrome web browser (Input field and Submit button)

Having trouble with the alignment of a textbox and button on Chrome, they're not displaying correctly. Here are examples from different browsers; notice how the textbox in Chrome is misaligned. Internet Explorer/Firefox https://i.stack.imgur.com/mf ...

What is the method to change the state of Bootstrap 4 buttons in a mobile view without using CSS classes as a reference?

I have a simple example featuring a few buttons displayed in a basic modular popup. I am curious about how the state changes from active to inactive as I don't see any visible change in my code. Initially, I attempted to use custom JS to add an "acti ...

Tips for incorporating a CSS class representing an image into a CodeIgniter form submission

<?php $data = array( 'class' => "btn btn-primary btn-lg", 'name' => 'report' ); echo '<span class="glyphicon glyphicon-exclamation-sign"></span> '; echo form_subm ...

Aligning an element vertically with the surrounding text on the same line

Trying to incorporate inline input range elements in a way that aligns with the line while also aligning with the right edge of the outer div has proven to be challenging. The HTML on the site is formatted using prettify, resulting in <span> elements ...

Am I on the right track in my understanding of how document and viewport relate to mouse position in JavaScript?

After reviewing responses from a previous inquiry, it is evident that both pertain to the x and y coordinates of mouse positions. In relation to the document and In relation to the viewport. I have delved into an article on QuirksMode, yet I feel ther ...

Creating a search form in Bootstrap 4 that is centered and expands to full width only on small screens

I'm currently working with a bootstrap v.4 navbar that has 3 elements in it. I've managed to align the elements evenly so that the search bar is centered in the navbar. However, when it collapses it takes up the full width of the screen. Here is ...

Modify the button transition background color in Bootstrap 4 for a new look

I am looking to customize the hover behavior of buttons on my website. By default, the buttons darken in color when hovered over. I was attempting to modify this behavior by adjusting variables in the _variables.scss file within the Bootstrap source code. ...

A peculiar trait of the Material-UI input select component in React JS is its ability to conceal the y

Currently, I am utilizing material-ui v3.1.2 in combination with react js v16.5.2. Throughout my page, I have implemented <TextField> with the select attribute in multiple locations. However, whenever I click on one of these TextField elements and th ...

Implementing text wrapping within input elements for optimal print.css layout

Can you help me with a print.css issue I'm experiencing? I am currently working on my print stylesheet and I've encountered a challenge where I need to word wrap input fields to ensure all the text is displayed correctly. Despite trying various ...

Solving the challenge of HTML checkbox design

I have successfully styled checkboxes with a background color, but now I want each checkbox to have a different color without having to rewrite a lot of code for each one. Check out the demo here .checkbox { display: inline-block; cursor: point ...

Adding an event listener to the built-in arrow buttons on the `<input type=number>` element is a simple way to enhance user interaction

<input type="number" id="test"> I'm trying to figure out how to set an event listener for the two arrow buttons on the right of this number input field. Typically, we can use jQuery like: $("#test").on("cl ...

It appears that the HTML links are non-responsive and appear to be arranged in an

I have a fairly straightforward website set up. It utilizes php to scan for images and then displays them one by one with navigation buttons at the top. These buttons allow users to switch back and forth between the images. At the top of the page, there ar ...

Exploring the world of mobile 3D transformations

I'm hoping to find a way to incorporate 3D transformations by utilizing the accelerometer on mobile devices within the following JavaScript code. Any assistance is greatly appreciated! $(document).mousemove(rotateScene); }); function rotateScene(e) ...

Tips for ensuring the accurate retrieval of prop values by waiting for the value to be set

Encountering an issue with the .toUpperCase() method within one of my components, resulting in the following error: TypeError: Cannot read properties of undefined (reading 'toUpperCase') This problem seems to stem from a race condition in fetc ...

What is the best way to create a centered vertical line with text in the middle?

I attempted to replicate a form that contains a vertical line <span class="vertical-line">or</span> with text centered in it! How can I create a similar appearance like this form? I considered using hr but it generates a horizontal ...