Utilizing Bootstrap 4 to design content with a full-width row

My goal is to create a grid layout similar to the one shown in the image:

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

This layout consists of a header followed by content divided into 3 columns. The content is separated by a full-width row with text in the center.

I am wondering about the correct structure in Bootstrap 4 to achieve this layout. I have searched the documentation but could not find any relevant information.

I attempted the following structure:

<div class="container">
 <div class="row">
  <div class="col">content</div>
  <div class="col">content</div>
  <div class="col">content</div>
 </div>
</div>

<div class="bg-dark py-4 my-4">
   <div class="container h-100">
      <div class="row h-100 align-items-center text-white">
        <div class="col-lg-12 text-center">
          <p>Middle Text</p>
        </div>
      </div>
    </div>
</div>

<div class="container">
 <div class="row">
  <div class="col">content</div>
  <div class="col">content</div>
  <div class="col">content</div>
 </div>
</div>

...and so on...

I am unsure if it is necessary to open and close a div container for each section of content. Any guidance would be appreciated. Thank you.

Answer №1

Discover a great example utilizing the amazing bootstrap 4 layout grid, as well as the superb spacing.

Enhance your site's appearance by centering and padding its contents horizontally using Containers. Opt for .container for responsive pixel width or .container-fluid for width: 100% across all viewport and device sizes.


I've incorporated some colors to resemble your desired outcome.
For an in-depth understanding, I urge you to delve into the Bootstrap documentation
It's comprehensive and will prove invaluable for your upcoming projects.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8>
<title>Bootstrap 4</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</head>
<body>
<div class="pb-2 mt-4 mb-2 border-bottom bg-primary">
<div class="container">
<h1 class="ml-5 ">Site title</h1>
</div>
</div>
<div class="container">
<div class="row container">
<div class="col-1"></div>
<div class="col-3 col-md m-1 bg-secondary">
<br>
<p>CONTENT</p>
<br>
</div>
<div class="col-3 col-md m-1 bg-secondary">
<br>
<p>CONTENT</p>
<br>
</div>
...
...
...
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</body>
</html>

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

The drop-shadow filter is not functioning properly on the dropdown menu in Safari

https://i.sstatic.net/PIWly.png --> image displayed when the "products" Nav item is hovered, showing a dropdown menu https://i.sstatic.net/YHX1g.png --> image of the "products" Nav item after hovering is removed (shadow remains even when the dropdow ...

What is the correct way to show a PHP script as an HTML page following an AJAX call?

Attempting to utilize AJAX to call a php file that will display an html page from my js. Below is the php file in question: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv=& ...

Toggle button based on text input to activate or deactivate

I need help with a script that will enable a button only when all required input fields are filled and a checkbox is checked. Currently, the button is being enabled even if only the last input field is filled. Can anyone assist? js $(document).ready(func ...

Creating dynamic CSS backgrounds that scroll horizontally

Styling with CSS #container { min-width: 800px; max-width: 1000px; height: 100%; margin: 0 auto; text-align: left; } #left-section { height: 100%; position: relative; float: left; ...

Adjust the navigation text and logo color as you scroll on the page

I am new to HTML and CSS and I am working on a website with PagePiling.js scrolling feature. I want to change the color of my logo image and navigation text dynamically as I scroll to the next section. Specifically, I only want the part of the logo and tex ...

Is the image loading promptly? Do we need to adjust the resolution?

Is there a way to decrease the loading time of images? For instance, if I have 20 identical images on my homepage (each sized at 1920x1080) This is the image: I want to crop the image to a fixed size. Here's the CSS code I am using: .startpage_im ...

Is there a way to showcase several items simultaneously on a bootstrap 5 carousel slide?

I currently have a bootstrap 5 carousel with controls that I want to modify. My goal is to create a slideshow where each slide displays 2 items, and I can scroll through one image at a time. Starting from here: https://i.sstatic.net/ROgoL.png And ending h ...

Could it be questionable XHTML originating from a conventional Haskell library?

Currently, I am working on resolving an issue with a program that generates XHTML in Haskell from UTF-8 text. The program is supposed to turn strings of text into valid XHTML entities, but it seems to be failing in doing so. I have imported Text.XHtml.Tran ...

What is the syntax for implementing an if-else statement?

Just starting with algolia and looking for a hit template. Please take a look at the script below for the text/html template needed: <script type="text/html" id="hit-template"> <div class="hit"> <div class="hit-image"> <i ...

Adjust the size of CSS elements on hover while removing any margin

I am currently working on making my navigation bar elements larger when hovered over. However, I'm facing an issue where the rest of the website shifts downward slightly when I mouseover them, and it doesn't look good. Is there a way to increase ...

When running the function `.find('li')` on a `bs4.element.Tag` object, it returns None despite the presence of the <li> tag within the soup

As I work on parsing the content of a URL using BeautifulSoup after making a request with `requests.get()` (not displayed in the code), I am using the parser ""html.parser"". Below is a snippet from a larger script: print(f"subheading : {sub ...

Responsive Video Embed Using Bootstrap-5

I'm facing some challenges with Bootstrap responsive video embedding. It seems like the parent container is not responding to changes, only the content within the <iframe> tag is being responsive. Any idea what might be going wrong? .embed- ...

Creating a responsive image using Bootstrap with an SVG filter applied

I've been working on applying an SVG filter to responsive images in Bootstrap 4 by using the class "img-fluid" However, I'm facing an issue where the separation between images varies across different resolutions. It's fine on desktop, but o ...

Where should I put my script in order to fix the issue with my JSFiddle?

Every time I attempt to run it on my local machine, the numbers vanish and then reappear when I select the checkboxes, just as I intended. It seems like there might have been an issue with linking the external resource script. Can someone advise me on wher ...

When clicking on a different tab, the Bootstrap tab will shift to the left, outlining the new selection

While working with Bootstrap, I created a small footer with a tab. However, whenever I click on the second value, the entire div shifts to the left. How can I keep it in place? Below is my code along with two images depicting how the first tab aligns corr ...

Having difficulty expanding the window to full size with headless Chrome using Selenium in Python

I am struggling to make the headless chrome window reach its full size. Despite my efforts, the window size remains at the default of 800px by 600px. Can someone assist me in setting it to full screen? Here is my code snippet: from selenium import webdriv ...

Utilize Bootstrap to switch between 'collapse' and 'collapse in' depending on the device being used

I have a collapsible panel set to default "expand" (collapse in) and it is working well. However, I would like to make it "collapse" (shrink) for mobile and tablet devices. Is there any built-in feature in Bootstrap that can help me achieve this? <div ...

Developing a JavaScript program that automatically updates the score in a Tic Tac Toe

I am currently working on developing a "Tic Tac Toe" game, but I have encountered an issue. Everything is functioning properly except for one aspect: when the game concludes and all squares are filled with either O or X, or when either X or O wins, it doe ...

Modify the Primevue Class p-accordion-header only under certain conditions

I'm currently facing a challenge with customizing the styling of the primevue component class p-accordion-header based on the status of the rendered component determined by the variantNumber. Here's a snippet of my code: <Accordion :multiple= ...

Using JavaScript to Filter XML Data within the DOM

I'm currently working on a project to enhance my JavaScript skills. I've successfully managed to retrieve data and display it in an HTML document using JavaScript. My next goal is to implement a search feature to filter through the list, but I en ...