End of container Bootstrap 4 row with two columns at the edge

I'm currently working on an angular project with bootstrap 4.

Within the container, there are two rows. I specifically want one row to always be positioned at the bottom of the container.

Despite trying methods like justify-content: flex-end;, bottom:0;, and others, I haven't been able to achieve the desired layout.

It's important to note that the parent component only has min-height: 100vh; in its CSS. (This ensures the board always fills the full height)

Below is a snippet of the code for better understanding:

<div class="sight-slider bg-success">
    slider goes here <br>
    slider goes here <br>
</div>
<div class="container">
   <div class="row">
        <div class="col-12 sight-info">
            <h2> Title of Sight </h2>
            <div class="sight-description">
                Lorem, ipsum dolor sit amet consectetur adipisicing elit. Unde culpa officiis obcaecati cupiditate 
                consequatur ducimus molestiae, quod quos incidunt! Laboriosam ab 
                modi nobis nesciunt voluptate eum tempora pariatur possimus et?
                Lorem, ipsum dolor sit amet consectetur adipisicing elit. Unde culpa officiis obcaecati cupiditate 
                consequatur ducimus molestiae, quod quos incidunt! Laboriosam ab 
                modi nobis nesciunt voluptate eum tempora pariatur possimus et?
            </div>
            <div class="sight-logic-info">
                Bla <br>
                Phone <br>
                Hours <br>
                Website
            </div>
        </div>
    </div>
    <div class="row btn-controls"> <!-- THIS ROW I NEED AT BOTTOM -->
        <div class="col-3 bg-danger">
            <button type="button" class="btn btn-exit">X</button>
        </div>
        <div class="col-9 bg-warning">
            <button type="button" class="btn btn-go">Go to location</button>
        </div>
    </div>
</div>

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

Answer №1

When working with Bootstrap, there are several built-in classes that can be really helpful. For example, to ensure the parent container has a minimum height of 100% of the viewport height, you can use the min-height:100vh property and apply it to the parent div. Additionally, by utilizing Bootstrap classes like .flex-column, you can easily create a layout with multiple flex containers stacked vertically.

To make sure a container fills the remaining space within its parent, setting flex:1; or flex-grow:1; is necessary, along with a custom class for additional styling purposes.

Lastly, using margin-top:auto with the provided class mt-auto can help position elements at the bottom of the container if needed.

/* Custom CSS Classes */

.min-h100vh {
  min-height: 100vh;
}

.flex-1 {
  flex: 1;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" />
<div class=" d-flex flex-column min-h100vh"><!-- Flexbox set to column layout to fill window -->
  <div class="sight-slider bg-success">
    slider content here
  </div>
  <div class="container flex-1 d-flex flex-column "><!-- Single column layout filling remaining space -->
    <div class="row">
      <div class="col-12 sight-info">
        <h2> Title of Sight </h2>
        <div class="sight-description">
          Lorem ipsum dolor ...
        </div>
        <div class="sight-logic-info">
          Additional information goes here...
        </div>
      </div>
    </div>
    <div class="row btn-controls mt-auto"><!-- Pushed to bottom with margin-top:auto; -->
      <div class="col-3 bg-danger">
        <button type="button" class="btn btn-exit">X</button>
      </div>
      <div class="col-9 bg-warning">
        <button type="button" class="btn btn-go">Go to location</button>
      </div>
    </div>
  </div>

If you need more information on Bootstrap utility classes related to flexbox, refer to the official documentation links - Flex Utilities and for margin and padding utilities, visit Spacing Utilities.

Answer №2

If there are 2 elements inside the .container class (namely div.row and div.row.btn-controls), you can utilize the properties of flex, column, and justification as space-between. An example implementation would be:

.container {
  display: flex;
  justify-content: space-between;
  flex-direction: column;
}

This setup ensures that the row will remain at the bottom.

Alternatively, depending on the specific context, another solution could involve setting bottom: 0 along with declaring a position value of relative or absolute. In the case of absolute positioning, the parent element should have a position set to relative in order to serve as a reference point.

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

Express.js's Handlebars failing to render elements from an array

I am currently developing an Express.js application that utilizes Handlebars for templating. One of the routes in my application fetches station data from MongoDB using Mongoose and then passes it to a Handlebars template. Although most of the data is bein ...

The PageMethods function is successful when using a single parameter, but encounters an error when attempting to use two parameters, resulting in the

PageMethods worked perfectly when sending a single parameter to a code-behind aspx page. However, I encountered the error "Unknown web method" when attempting to provide two parameters (or an Object other than a String). The functional code in my aspx pag ...

Having trouble accessing specific results using Firestore's multiple orderBy (composite index) feature

I am facing an issue with a query that I run on various data types. Recently, one of the collections stopped returning results after I included orderBy clauses. getEntitiesOfType(entityType: EntityType): Observable<StructuralEntity[]> { const col ...

What are the steps to run and test the renovate bot on your local machine

Before setting up renovate to work with my Azure pipeline, I wanted to test it locally using npx renovate to ensure everything is working as expected and that my config file is properly configured. I ran npx renovate --platform local command. My project i ...

Tips for shifting objects from a horizontal row to a designated vertical column when switching to a smaller display

I am currently utilizing bootstrap to enhance my website layout for mobile view. The main challenge I'm facing involves transitioning items from a row to a column in a specific order. In this case, I have two items in a row and I would like the first ...

a basic three-tier flexible design with alignment to the lower right side

I am looking to create a dynamic header that adjusts based on the height of the svg logo and available width for the navigation: layout1: If there is not enough space for all navigation buttons (a) to fit in one row next to the svg, then the nav block sh ...

What is the proper way to combine two arrays containing objects together?

I am faced with the challenge of merging arrays and objects. Here is an example array I am working with: [ { name: "test", sub: { name: "asdf", sub: {} } }, { name: "models", sub: {} } ] ...

How is it possible that the SetTimeout code continues to run even after calling clearTimeout

I have this code snippet within my react component: //some code var timeout = null; //global variable //some more code useEffect(() => { if(...some condition) { console.log('test1'); timeout = setTimeout(() => { ...

How can I use regular expressions to locate a React JSX element that contains a specific attribute?

Currently conducting an audit within a vast codebase, my task involves searching for all instances of a component where it is utilized with a specific prop. I believe that using regex could prove beneficial in this situation; however, the challenge lies in ...

What is the process of incorporating a select form within a component?

I am currently working on creating a user registration form. Once the form is filled out and the submit button is clicked, I need the values from the form to be displayed in a specific <p id="data></p> component. Can anyone assist me with this ...

Transmitting multiple file attachments to a PHP file through AJAX

In my form, I have the following HTML code: <input type="file" id="attachments" name="attachments" multiple> I've already implemented a JavaScript function that handles form submission using AJAX, but it doesn't handle uploaded files. Wi ...

Avoiding HTML (JSX) tag duplication in React Component

Having the same code in my React component multiple times is becoming repetitive and inefficient. Is there a way to follow the DRY principle and avoid repeating this code? While creating a landing page with Sass styling, I noticed that I am duplicating t ...

Is JSON formatting essential for Highcharts? How to divide and preprocess data for creating charts?

Seeking assistance with extracting data from a JSON at the following link: I am attempting to integrate this data into highcharts for visualization. Although I have a functioning chart, I am struggling with properly formatting the JSON mentioned above du ...

Struggling to add phantom-js to my Angular project

I'm looking to incorporate the phantomJS library into my Angular 4 project for continuous integration with Jenkins. No matter what method I try, I keep encountering the same (or similar) error. For instance, when following this tutorial and attemptin ...

Switch up the positioning of elements using jQuery

My webpage contains multiple elements that are absolutely positioned with the CSS attribute "top." I am looking to adjust the top position of each element by 20px. This involves retrieving the current top position and adding 20px to it. The quantity of e ...

Learn the technique of coding HTML within inline JavaScript, along with implementing CSS inline styling

I'm looking for a way to incorporate HTML within inline JavaScript, along with CSS inline styles. Can someone provide guidance on how to achieve this? For example, something like the following code snippet: <p><span style="color: #00ff00;"&g ...

Ensure that only one menu with a specific class is open at any given time

My goal is to ensure that both menus cannot be open simultaneously. The desired behavior is as follows: When one menu is already open and you click on another, the first one should automatically close. For a better understanding of what I am trying to achi ...

Implementing a map display feature in Angular using search results

I need assistance with displaying a map in an Angular 2 application. I also want to be able to highlight specific locations or areas based on certain data points. For example: 1. Showing voting results on the map by highlighting different colored areas. ...

What methods can I use to make sure the right side of my React form is properly aligned for a polished appearance?

Trying to create a React component with multiple input field tables, the challenge is aligning the right side of the table correctly. The issue lies in inconsistent alignment of content within the cells leading to disruption in overall layout. Experimente ...

Ways to determine if the user is using a mobile device with CSS

Is there a way to detect mobile users using CSS? I am working on a project that requires detecting mobile users, but I am unsure how to do so. Can you provide any guidance? ...