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>

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

Using AngularJS to filter and order items in an ng-repeat loop with multiple variables

I hold a dataset with employment history. There are two fields for the employment dateTo: yearTo, monthTo To accurately sort the employment history by the most recent dateTo, I utilize the following code: <tr id="employment_history_" ng-repeat="histo ...

Enhance your website's user experience with jQuery by implementing smooth scrolling alongside

I have a fixed header at the top of my page. When it scrolls, I want to ensure that it does not cover or hide any of my content, especially the top portion of the section. // This code enables smooth scrolling (source: css-tricks) $('a[href*="#"]:no ...

What is the process for capturing a window screenshot using Node.js?

I am currently conducting research to discover a way to capture a screenshot of a window using Node.js. I have been attempting to achieve this with node-ffi, but I am facing some difficulties at the moment: var ffi = require('ffi'); var user32 ...

Enhancing PHP function speed through pre-compilation with Ajax

I am curious about compiling server side functions in PHP with Ajax, specifically when multiple asynchronous calls are made to the same server side script. Let's consider a PHP script called "msg.php": <?php function msg(){ $list1 = "hello world ...

Display Material UI icons as markers within Highcharts

Does anyone know how to use Material UI icons as markers in rendering? I have been searching for documentation but can't seem to find a clear explanation. Any guidance would be greatly appreciated! ...

IE does not support hover effects

Having trouble with a hover effect that works in Chrome but not in MSIE. Are there any alternatives or fixes to make it work in MSIE? The hover/rollover effects I've tried all seem to have this issue in IE. normalize.css demo.css set2.css font- ...

Revamp the button's visual presentation when it is in an active state

Currently, I'm facing a challenge with altering the visual appearance of a button. Specifically, I want to make it resemble an arrow protruding from it, indicating that it is the active button. The button in question is enclosed within a card componen ...

"Utilizing React's useState feature to dynamically update numerous dropdown components

Here is a React component snippet: const [show, setshow] = useState(false); const handleShow = () => { setshow(!show); }; Accompanied by the following CSS styles: .show { display: block; } .dropdown_content { padding: 3px; display: none; po ...

I'm curious if there's a method to ensure that the content within a mat-card stays responsive

So I'm working with this mat-card: <mat-card> <mat-card-content> <div *ngFor="let siteSource of siteSources | paginate: { itemsPerPage: 5, currentPage: page};"> <site-details [site]='siteSource'></s ...

Material UI defaults remain unchanged despite any emotional influence

I'm currently experimenting with custom styling on a MaterialUI Typography component using the code snippet below: const StyledTitleTypography = styled(Typography)` color: 'black'; font-weight: 'bold'; `; <StyledTitleTypogr ...

What is the process for setting an object's property as a href in an AJAX call?

I've got a quick query. How can I assign an object's property to the href attribute? I've indicated the line with a comment. success: function (listOfTags) { let tagData = ''; $.each(listOfTags, function (i, tag) { ...

There is an issue showing up in the console: $(…).datepicker is not defined as a function

I am new to using HTML with JavaScript. I attempted to implement a datepicker, but unfortunately, it is not working as expected. The error message I am receiving is '$(...).datepicker is not a function' in the console. I am utilizing multiple f ...

Guidelines for accessing the value of the parent function upon clicking the button within the child function?

I have a pair of buttons labeled as ok and cancel. <div class="buttons-div"> <button class='cancel'>Cancel</button> <button class='ok'>Ok</button> </div> The functions I am working wi ...

Switch back and forth between two different function loops by clicking

I have implemented two sets of functions that animate an SVG: one set runs in a vertical loop (Rightscale.verticalUp and Rightscale.verticalDown) and the other in a horizontal loop (Rightscale.horizontalUp or Rightscale.horizontalDown). On clicking the SVG ...

Unable to retrieve device UUID using capacitor/device on Android

I'm currently attempting to obtain the UUID of my devices so that I can send targeted notifications via Firebase. My front end and back end are connected, enabling the back end to send notifications to the front end using Firebase. However, all I am a ...

Issue with unit testing a ViewportRuler in Angular 2 Material Library

I am currently working on an Angular2 component that includes a tab control from @angular/material. During testing of my component (refer to the simplified code below), I encountered the following error: Error: Error in ./MdTabHeader class MdTabHeader - ...

An API built with Mongoose, Express, and Node.js is currently only able to send a single image

I have a buffer array that needs to be converted into images and sent to the user. The issue is that the current code only sends one image: const express = require("express"); const asyncHandler = require("express-async-handler"); const ...

Retrieving a local variable within an AngularJS controller

Examining the code provided below: app.controller('Controller', function($scope, $http){ $scope.rep = []; $scope.tot = { name: '', marketValue: 0, cash: 0, legend: 'none' }; ...

Attempting to adjust the width of a text animation loaded with jQuery using Textillate, but encountering difficulties

I found a captivating animation on this website: http://codepen.io/jschr/pen/GaJCi Currently, I am integrating it into my project. #content { position: relative; margin-left: auto; margin-right: auto; width: 1000px; height: 700px; } ...

"Utilize Ajax and PHP to seamlessly upload a PDF file directly into a MYSQL database

I am trying to figure out how to upload a pdf file from user input into my MySQL database. I have provided code that displays a user registration form with the option to upload a PDF file. My goal is to use AJAX to post this data to a PHP script for storag ...