Create a unique layout with Bootstrap flexbox featuring 2 rows within 1 column, perfectly aligning all the

I am aiming to create a unique layout with two rows, each spanning the full width of the viewport but containing only one column. The top row should have its content aligned at the bottom, while the bottom row should display its content at the top.

After experimenting with Bootstrap examples, I managed to achieve this layout: https://codepen.io/afagard/pen/QWpJWze

Despite the layout appearing as intended, I still question whether my approach is correct. I initially set the container height to 100vh, but it did not affect the flexboxes as expected. For now, I divided the rows into equal heights of 50vh. As someone more accustomed to backend work, I am taking this opportunity to delve into learning flexbox techniques.

https://i.sstatic.net/UvmY5.jpg

Answer №1

Here is a simple example of using flexbox with bootstrap classes only, no extra CSS needed:

<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a5c7cacad1d6d1d7c4d5e5908b958b94">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">


<div class="container-fluid p-0 vh-100 d-flex flex-column text-center">
  
  <div class="flex-grow-1 d-flex flex-column bg-primary">
    <div class="mt-auto">
      Top half
    </div>
  </div>
  
  <div class="flex-grow-1 d-flex flex-column bg-secondary">
    <div class="mb-auto">
      Bottom half
    </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

What is the method for displaying the delete icon, a child component located within the Menu Item, upon hovering over it using Material UI CSS syntax?

My goal is to display the delete icon when hovering over a specific menu item that is being mapped using the map function. The desired functionality is for the delete icon to appear on the corresponding menu item when it is hovered over. I attempted to i ...

Using localStorage.getItem() to select SVG <g> elements

On my website, I have incorporated two <iframe> elements that link to separate HTML files containing SVG images. When a user clicks on an svg element in file1.html, an ID number is generated and stored using the code: localStorage.setItem("element1i ...

Mysterious element materializing within the code featuring the attribute "data-original-title"

I've noticed a mysterious div that keeps popping up in the code of the website I'm currently working on. It seems like countless developers have tinkered with this project over time. This page is utilizing Bootstrap and is based on a .Net forms ...

Arrangement of divs stacked in a flowing design

My goal is to create a website layout with two columns. The left column will contain two divs, while the right column will have four divs. Each div can vary in height and should not trigger a vertical scrollbar on the main body; only within each individual ...

Extracting <p> elements from a separate HTML file and cycling through them

I successfully created a website using only HTML, JavaScript, and jQuery without any server-side scripting or language. Within my website, I have a simple stream.html page that remains unstyled with no CSS formatting. <html> <head> </head& ...

Embed a PHP webpage into an HTML page using JavaScript

I have been trying to utilize this code in order to embed a PHP page within an HTML page using JavaScript. However, it is not functioning as expected. The code snippet is provided below: <html> .... <div id="home" style="background: #000;backgrou ...

Ensuring DIVs are completely contained within their parent DIV using Fullscreen CSS and a height of

I found a nearly-perfect design using the code below: https://i.sstatic.net/56i2E.png This code provides the layout mentioned: <!DOCTYPE html> <head> <meta charset="UTF-8"> <link rel="stylesheet" href="http://maxcdn. ...

What is the best way to ensure uniform container sizes and properly align images within them?

Customize Image Sizes: Is there a way to set a standard container size and adjust image sizes properly without compromising clarity or aesthetics? The images vary in dimensions, so should they be standardized or is there another solution? Code snippet: ...

The <footer> element refuses to be placed at the bottom of the page

Struggling to keep my <footer> tag at the bottom of my page despite trying various techniques. Check out my website below to see the issue in action: ...

How to extract hidden text upon clicking a button using beautifulsoup and python?

I am currently attempting to extract data from the following URL: Website The website contains text that is hidden until clicked, and its HTML code remains hidden until certain buttons are clicked. Initial view: After clicking: Can anyone suggest a met ...

Loading Animation for Pages and Tables

I'm experiencing a choppy and sudden transition when switching between two pages that contain tables populated using ng-repeat. Upon loading, the footer is positioned halfway up the page below the table heading until the table loads and the layout adj ...

Organize table information using rowspan functionality

View of Current Table I am looking to implement a side column in my table using rowspan to group dates within each pay period. The goal is for a supervisor to be able to create a new pay period, which will assign a unique integer in the database and then ...

Full replacement of a cell within an HTML table

I have a scenario like the following: <table id="myTable"> <tr> <td class="1">cell 1</td> <td class="2">cell 2</td> </tr> <tr> <td class="3">cell 3</td> &l ...

Implementing a Timer on a Bootstrap Progress Bar Using JavaScript

I am currently working on a timer with a progress bar. The timer itself is functioning properly, but I am facing an issue with syncing the progress bar with the timer. I am utilizing the bootstrap progress bar for this project. If I remove the 'bar&ap ...

What is the process for forming an object from points so that it can be easily integrated into a graphical user interface (GUI)?

I have been following Bruno Simons' Three.js tutorial on Mixing Html with WebGl, specifically the part where you try to attach a text box to a 3D model. I have imported the GUI and set it up, but I am struggling to understand what I need to 'gui. ...

Is there a way to adjust the size of this map?

I’m attempting to adjust the dimensions of the div.wx-imap-pane.wx-module to a height of 346px and a width of 1727px using greasemonkey, but I’m struggling to make the change take effect. My attempt: div#div.wx-imap-pane.wx-module, div#div.wx-imap-pa ...

Vue.js - Problem with loading image on screen

Although I have experience with React, I am currently facing the challenge of using Vue for a code assessment for the first time. My struggle lies in creating a reusable image component with WAI-ARIA accessibility. Despite my efforts, I cannot get the imag ...

What is the method for incorporating an Emmet shortcut within a tabstop when creating a VSCode Snippet?

I have customized several User Snippets in my VSCode by adding them to the html.json file. My goal is to easily edit content both inside and outside of PHP tags using tab functionality. For instance, here is a snippet for an if-else statement with PHP emb ...

Expanding the outer div with Jquery's append() function to accommodate the inner div elements perfectly

I am facing an issue where my outer div does not expand automatically to fit the elements I append inside it using jQuery. The structure of my div is as follows: <div class="well" id='expand'> <div class="container"> < ...

Problem with user scalability in desktop browsers: when zooming out to 33% and lower, all CSS vanishes

Having trouble understanding why my styling disappears at 33% zoom on Chrome and even worse at 75% on IE11. <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1"> <meta name="viewport" content="w ...