What is the best way to align a button at the bottom using Bootstrap 4?

My question is not as straightforward as the title suggests, but I couldn't think of a better one.

Initial Configuration:

I am using Bootstrap v4.0.0-alpha.2 and I removed this simple sidebar. I also added flex: true in my _library-variable-overrides.scss (using css-burrito) just to test it out, so I'm open to turning it off. ;-)

What I Aim to Achieve:

I want a button in the sidebar that is aligned at the bottom. Ideally, centered horizontally within the sidebar with about 1em margin from the bottom.

Current Code Setup:

_shell.scss & _sidenav.scss:

#shell-wrapper {
    padding-left: 0;
    transition: all 0.5s ease;
}

#shell-wrapper.toggled {
    padding-left: 250px;

    #shell-content-wrapper {
        position: absolute;
        margin-right: -250px;
    }
}

@media(min-width:768px) {
    #shell-wrapper {
        padding-left: 250px;
    }
    
    #shell-wrapper.toggled {
        padding-left: 0;

        #shell-content-wrapper {
            position: relative;
            margin-right: 0;
        }
    }

    #shell-content-wrapper {
        padding: 20px;
        position: relative;
    }
}


#sidenav-wrapper {
    z-index: 1000;
    position: fixed;
    left: 250px;
    width: 0;
    height: 100%;
    margin-left: -250px;
    overflow-y: auto;
    background: #000;
    transition: all 0.5s ease;
}

#shell-wrapper.toggled { 
    #sidenav-wrapper {
        width: 250px;
    }
}

#shell-content-wrapper {
    width: 100%;
    position: absolute;
    padding: 15px;
}

/* Sidenav Styles */

.sidenav-nav {
    position: absolute;
    top: 0;
    width: 250px;
    margin: 0;
    padding: 0;
    list-style: none;

    li {
        text-indent: 20px;
        line-height: 40px;

        a {
            display: block;
            text-decoration: none;
            color: #999999;
        }

        a:hover {
            text-decoration: none;
            color: #fff;
            background: rgba(255, 255, 255, 0.2);
        }

        a:active, a:focus {
            text-decoration: none;
        }
    }

    >.sidenav-brand {
        height: 65px;
        font-size: 18px;
        line-height: 60px;

        a {
            color: #999999;
        }

        a:hover {
            color: #fff;
            background: none;
        }
    }
}

@media(min-width:768px) {
    #sidenav-wrapper {
        width: 250px;
    }
    
    #shell-wrapper.toggled #sidenav-wrapper {
        width: 0;
    }

}

and index.html:

<div id="shell-wrapper" class="toggled">
  <div id="sidenav-wrapper">
    <ul class="sidenav-nav">
      <li class="sidenav-brand">
        <a href="#">Brand</a>
      </li>
      <li>
        <a href="#">Item 1</a>
      </li>
      <li>
        <a href="#">Item 2</a>
      </li>
      <li id="logout">
        <button class="btn btn-danger-outline">Logout</button>
      </li>
    </ul>
  </div>
  <button class="navbar-toggler" type="button">
    &#9776;
  </button>
  <div id="shell-content-wrapper">
    <div class="container-fluid">
      <div class="row">
        <div class="col-lg-12">
          <!--Main Content Here-->
        </div>
      </div>
    </div>
  </div>
</div>

The main concern is with the logout button. My attempt was adding this code snippet:

.sidenav-nav {
    height: 100%;
}

#logout {
    position: absolute;
    bottom: 1em;
}

While it met my requirements on a desktop browser, upon switching to mobile view in Chrome, the logout button vanished completely.

Answer №1

While I have not personally used css-buritto, a potential solution could involve assigning a class or id to the button and utilizing the position:relative property to adjust its placement. By setting a bottom: 1em value, you may be able to align the button at the bottom of the section. Additionally, exploring other position properties such as fixed might offer alternative positioning options.

As previously mentioned, consider the following approach:

#logout {
    position: relative;
    bottom: 1em;
}

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 best way to align my clip-path's text with the center of the viewport and ensure that all of the clip-path's text is visible?

Check out my React component demo: https://codesandbox.io/s/epic-brown-osiq1. I am currently utilizing the values of viewBox, getBBox, and getBoundingClientRect() to perform calculations for positioning elements. At the moment, I have hardcoded some values ...

Remove the whitespace between the <h2> element and the CSS animation

Is there a way to remove the space between h2 and the animation in the following code snippet? .loader { border: 16px solid #f3f3f3; border-radius: 50%; border-top: 16px solid #3498db; width: 50px; height: 50px; -webkit-animation: spin 2s li ...

Arranging divs of varying heights in a grid formation

I am working on a website layout that needs to look like the image provided: The red section represents the desktop version, while the yellow section represents the mobile version. I can easily switch between the two layouts using media queries. My chall ...

Issue with displaying modal and backdrop specifically on iPhone in Angular 13

Within our Angular 13 application, we have a modal component. The component's CSS includes the :host selector for the root element, which also serves as the style for the backdrop: :host { position: absolute; background: rgba(0, 0, 0, 0.5); widt ...

Display of dual currencies in Magento

I am experiencing a small issue on my Magento shop that I can't seem to figure out. When I go to the frontpage, the categories are listed in the correct currency (kr.), but when I hover over them, it changes to krDKK. Both represent the same currency ...

using a tag in flex can disrupt the arrangement of the box's design

What could be the reason for this issue? Is it possible to make the hyperlink appear inline with the rest of the text? .test { padding: 25px; display: flex; height: 100%; text-align: center; font-size: 25px; font-weight: 600; ...

Experiencing issues with properly rendering the Bootstrap year calendar and encountering difficulties with the date picker functionality

Having trouble implementing the bootstrap-year-calendar on my website. The JavaScript functionality and the display of the calendar are not working as expected. I want to show the calendar horizontally like the example in the link, but it is currently dis ...

What could be the issue with the functionality of my slider link url?

The slider is functional, but the links are not working properly. Each slide should redirect to a different URL For instance: Slide 1 with a link to Bing, Slide 2 with a link to Google, Slide 3 with a link to Yahoo. I am unable to incorporate Javascri ...

Functions perfectly on jsfiddle, but encounters issues on Dreamweaver

After reading that I needed to add back the event handler for my code to work in Dreamweaver from JS Fiddle, I made sure it was included but still can't get it to function. The Demo can be found here: http://jsfiddle.net/EfLJJ/6/ Below is my JavaScri ...

What is the best way to reduce the viewport size of my application to 67% of the Chrome browser view?

Recently, I acquired an Angular application that comes with hundreds of SCSS files. However, when the application is viewed in a browser set to 100%, it appears ugly and too zoomed in. Applying zoom: 70%; to the index.html body improves the appearance, bu ...

Folding at the start of sentences within a paragraph tag

Utilizing TinyMCE for my users to generate their own web pages is my current project. My main objective is to ensure that whatever content users type into the editor appears exactly as it does when published on the page. I am close to achieving this, howev ...

An error occurs when trying to modify the classList, resulting in an Uncaught TypeError for setting an indexed property

I am attempting to modify the classes of multiple sibling elements when a click event occurs. Some of these elements may have multiple classes, but I always want to change the first class. Below is the code that I created: let classList = event.currentTa ...

Unable to pass the new value to the onclick function

I am currently working with Gridster.js in combination with Twitter Bootstrap. My goal is to have a modal pop up when I double-click on a grid, allowing for customization of the grid. Currently, I am focusing only on the delete option. The issue I am fac ...

Looking for a more efficient method to code this dynamic jQuery pagination loader?

Currently, my website uses a pager that loads the page when you click on the page numbers. The code shows the closest 10 pages along with arrows to navigate to the first, previous, next, and last pages. I am aiming to develop jQuery code that can update t ...

The Fade In effect in jQuery causes my fixed header to overlap with images on the page

This is the javascript snippet using jquery <script type="text/javascript> $(document).ready(function () { $('#showhidetarget').hide(); $('a#showhidetrigger').click(function () { $('#showhidetarget&apo ...

Using CSS to encompass a group of words within a circular shape

I am attempting to encircle multiple words within one circle, but currently each word is enclosed in its own circle. Below is the code I am currently using. HTML <div class="numberCircle"> <span>Circle all words</span> </div> ...

Utilizing Javascript to implement a tooltip feature for dynamically inserted text

I recently incorporated a brief jQuery tooltip plugin into my site. It consists of approximately ten lines of code and works smoothly, as demonstrated in this demo. However, I encountered an issue when attempting to add new text that should also trigger t ...

Methods for removing a CSS element that specifically targets a table using JavaScript

I am facing an issue with my Drupal site where the CSS for a Google Org Chart is being overridden by some existing styles. Below is the code snippet in question. The CSS I need to eliminate: .MainBlock table td { border-right: 1px solid #045273; bo ...

Creating a hover effect for displaying image masks

My website features a profile page displaying the user's photo. I am attempting to create a functionality where when the user hovers over their photo, a transparent mask with text appears allowing them to update their profile picture via a modal. How ...

Conceal flexbox item depending on neighboring element dimensions or content

I've encountered an issue while using a flexbox to display two elements side by side. The left element contains text, while the right one holds a number. When the value in the right element has at least 7 digits ( > 999,999 or < -999,999), I ne ...