Is "align-content-end" the correct way to align the div to the bottom?

I recently started learning BootStrap and delving into web development. Despite watching numerous video tutorials and reading the documentation, I am still struggling with layout issues – something isn't quite clicking for me.

My goal is to create left and right panels that will contain additional content not visible in the snippet provided. I want the yellow and green button bars to always align at the bottom of the container, regardless of the other content in the panels.

After spending several hours on this, I'm not sure if my approach to laying out the elements is incorrect or if I'm not utilizing the align-content-end class correctly.

(I'm unsure why the code below is generating an error – it appears to be functional)


Current layout:

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


Desired layout:

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

#events-tab-container {
  /* background: gray; */
  height: 90vh;
}

#left-panel {
  background: lightcoral;
  border: 1px solid gray;
  border-radius: 10px;
  /* margin-right: 10px; */
}

#right-panel {
  background: lightskyblue;
  border: 1px solid gray;
  border-radius: 10px;
}

#button-bar-left {
  background: yellow;
}

#button-bar-right {
  background: lightgreen;
}
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>


<div id="events-tab-container" class="container">
  <div class="row h-100">

    <div id="left-panel" class="col col-8">
      left

      <div id="button-bar-left" class="row d-flex justify-content-end align-content-end">
        <button id="cancel-event-btn" class="btn btn-sm btn-secondary mr-2">Cancel</button>
        <button id="save-event-btn" class="btn btn-sm btn-primary mr-2">Save Event</button>
      </div>
    </div>

    <div id="right-panel" class="col col-4">

      right

      <div id="button-bar-right" class="row d-flex justify-content-end align-content-end">
        <button id="new-event-btn" class="btn btn-sm btn-primary mr-2">New Event</button>
      </div>
    </div>
  </div>

  <!-- END EVENTS CONTAINER -->
</div>

Answer №1

Ensure the columns have the classes d-flex flex-column, and also add mt-auto to create auto top margins...

<div id="events-tab-container" class="container">
    <div class="row h-100">

        <div id="left-panel" class="col col-8 d-flex flex-column">
            left

            <div id="button-bar-left" class="d-flex mt-auto justify-content-end align-content-end">
                <button id="cancel-event-btn" class="btn btn-sm btn-secondary mr-2">Cancel</button>
                <button id="save-event-btn" class="btn btn-sm btn-primary mr-2">Save Event</button>
            </div>
        </div>

        <div id="right-panel" class="col col-4 d-flex flex-column">

            right

            <div id="button-bar-right" class="d-flex flex-column mt-auto justify-content-end align-items-end">
                <button id="new-event-btn" class="btn btn-sm btn-primary mr-2">New Event</button>
            </div>
        </div>
    </div>
</div>

Answer №2

To fully utilize the awesome properties of the bars, consider setting the parent element to display: flex.

Here's an example demonstrating the use of flex:

.left-panel {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

After that, adjust the margin of the bar itself to position it as desired.

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

Struggling to find a solution for altering font color with jQuery while creating a straightforward menu

I'm having trouble changing the color of the active button pressed to "color:white;"... Here is the link to the jsfiddle: http://jsfiddle.net/wLXBR/ Apologies for the clutter in the file, my css is located at the bottom of the CSS box (Foundation cod ...

The onclick function in the Navbar div fails to work for inner elements

Within my navbar, there is a .dropbtn div that I want to trigger a dropdown function when clicked. However, only the text "TOTAL" seems to activate this function onclick. The <span> and <i> elements inside the .dropbtn do not respond to clicks ...

Is it possible to change the tab to "home-tab" by clicking on navbar-brand in Bootstrap 5 using JavaScript?

This is my first venture into web development, so please bear with me as I navigate through this unfamiliar territory. In my project, I have a function called Navbar() that generates a navigation bar on the webpage by wrapping all elements with the navbar ...

Trouble with Metro UI Library: CSS not loading properly

I am having trouble with the navbar CSS on my website while using the Metro UI CSS library. Check out my HTML code: <!DOCTYPE html> <html lang="en"> <head> <title>TelePrint Blog</title> <link rel="stylesheet" href= ...

Having troubles with Navbar svg images not loading on certain pages on the express/ejs app?

Hello there, I'm encountering an issue with my navbar in an express app. The navbar is saved as a partial and included in a boilerplate wrapper used on most pages. Here's a snippet of how it looks: <h1>HELLO<h1> Within the boilerplat ...

What are the steps to ensure that this iframe adjusts perfectly to the page in terms of both vertical and horizontal dimensions

I have a sandbox from Material UI that you can view at this link: https://codesandbox.io/s/material-demo-forked-c8e39?file=/demo.js Upon loading the page, an iframe displays some HTML content. Although the width fits perfectly, there are two vertical scro ...

The appearance of a CSS select box may vary across different computers and web browsers

The appearance of a select box in HTML can vary between different computers and browsers. For example, on one computer using Google Chrome, the select box may look like this: https://i.stack.imgur.com/g2Xnn.png However, on my computer with Google Chrome, ...

yii2 truncates CSS classes in the email templates

My email sending process involves using a template: $content='Message'; Yii::$app->mailer->compose('@app/mail/templates/templ', ['content'=>$content]) ->setFrom('<a href="/cdn-cgi/l/email-protection" c ...

What is the process for incorporating a full-page blog into a blog preview?

I customized a template, but there is a blog section within the div that I am struggling to replicate. Here is the test website for reference: Below is the HTML code for the blog section: <!-- Blog Start --> <section class="section bg ...

Ensure that the child div completely fills the entire width of its parent container,

My table contains another table within each row. I have implemented scroll overflow for the mobile view, but this causes the rows to not fill the available space and lose their background when scrolling. I have experimented with using width: fit-content a ...

Adjusting webpage zoom based on different screen sizes

Hey there, I ran into an issue with my web page design. It looks great on my desktop monitors, but when I checked it on my laptop, things went haywire. Strangely, adjusting the zoom to 67% seemed to fix the problem. Both screens have a resolution of 1920 ...

HTML / CSS / JavaScript Integrated Development Environment with Real-time Preview Window

As I've been exploring different options, I've noticed a small but impactful nuance. When working with jQuery or other UI tools, I really enjoy being able to see my changes instantly. While Adobe Dreamweaver's live view port offers this func ...

In the realm of HTML Canvas, polygons intricately intertwine with one another

Currently, I am attempting to create multiple polygons from a large JSON file. Instead of being separate, the polygons seem to be connected in some way. https://i.sstatic.net/Ce216.png The project is being developed in next.js. Below are the relevant co ...

Are there any reliable sources for a complete list of browser CSS properties?

Is there a way to easily access a comprehensive list of CSS properties supported by specific browsers, particularly IE8? Any suggestions on where I can find this information? ...

The dropdown feature in the bootstrap4 navbar causes the navigation items to shift and adjust their

I am currently working on a navigation bar using Bootstrap4 and I've added a nav-item button to dropdown a menu. However, the issue I'm facing is that when the menu drops down, it pushes other nav-items around, causing them to change position. Th ...

unable to display options in my select element | Angular and Ionic

I need help displaying my category options: <div class="row" style="margin-bottom:15px;padding:0;padding-top:0px;padding-bottom:0px;"> <div class="col col-white" style="height:45px;background-color:#EDEEF1;padding-top:6px"> <div class=" ...

How can I center two images using a hover effect in WordPress?

When the mouse hovers over an image, it changes to another image. Everything works smoothly except for one issue - the image is not centered. Below is the code I am currently using: HTML: <figure> <a> <img class="hover" src="na ...

Design interactive elements such as buttons and input fields inspired by the layout of Google websites

Does anyone know how to achieve the sleek, lightweight buttons and text boxes seen on Google's web pages like Google Search, Google Plus, and Google Play? I am currently using JSP and CSS, but I am open to incorporating jQuery if necessary. Any help w ...

Best placement for transition effects in a dropdown menu animation

<div class="dropdown"> <button class="dropbtn">ALAT</button> <div class="dropdown-content"> <a href="index2.php"><img src="home.jpg" class="home" width="7 ...

Change the appearance of the page when it is being displayed within an iframe using CSS

How can I display a webpage differently using CSS if it is within an iframe? I would like to use jQuery or JavaScript to switch to a different stylesheet specifically when the site is being displayed within an iframe. Any suggestions on how to achieve th ...