What is the reason that in Bootstrap, the buttons become full width when using "fixed-bottom," even though they are not full width without it?

My goal is to have 1 button positioned near the top and 2 buttons fixed at the bottom. However, when I add the fixed-bottom` class to the div containing the bottom-fixed buttons, it causes them to span the full width of the container. This results in the buttons not having the desired padding. On the other hand, without the "fixed-bottom" class, the buttons have the correct padding but are not in the right location.

I want all buttons to have consistent padding - whether fixed at the bottom or positioned at the top. Is there a simple solution for this issue (perhaps an additional/different class I am overlooking), or do I need to create a custom CSS class to ensure consistent button width?

This scenario involves a .Net MAUI app utilizing Blazor Hybrid and Bootstrap, running on the Android emulator.

Here is an example using the "fixed-bottom" class. The buttons are in the desired location, but the width is not as intended:

<div class="text-center d-flex flex-column" style="z-index: -1;">
  <button type="button" class="btn btn-primary btn-lg btn-block gsewq-button-primary" @onclick="SyncLookupValues">Sync Lookup Values</button>
</div>
<div class="text-center flex-column d-flex fixed-bottom">
    <button type="button" class="btn btn-primary btn-lg btn-block gsewq-button-primary" @onclick="Logout">Logout</button>
    <div class="vertical-spacer-1"></div>
    <button type="button" class="btn btn-primary btn-lg btn-block gsewq-button-primary" @onclick="ChangeEnvironment">Change Environment</button>
    <div class="vertical-spacer-7_5"></div>
</div>

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

To illustrate, when the "fixed-bottom" class is removed, the buttons have the desired size but are not positioned correctly:

<div class="text-center d-flex flex-column" style="z-index: -1;">
  <button type="button" class="btn btn-primary btn-lg btn-block gsewq-button-primary" @onclick="SyncLookupValues">Sync Lookup Values</button>
</div>
<div class="text-center flex-column d-flex">
    <button type="button" class="btn btn-primary btn-lg btn-block gsewq-button-primary" @onclick="Logout">Logout</button>
    <div class="vertical-spacer-1"></div>
    <button type="button" class="btn btn-primary btn-lg btn-block gsewq-button-primary" @onclick="ChangeEnvironment">Change Environment</button>
    <div class="vertical-spacer-7_5"></div>
</div>

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

Answer №1

fixed-bottom is a CSS class that positions an element at the bottom of the viewport.

.fixed-bottom {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1030;
}

btn-blocks is a deprecated class in Bootstrap 5, you should refer to the documentation for managing block buttons in Bootstrap 5 here.

.btn-block {
  display: block;
  width: 100%;
}

To add margin to your flex container, you can use mx-3.

If you want to learn more about flexbox, check out this helpful guide.

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

Update the background color of an li element upon clicking

Is there a way to change the background color upon clicking on the li anchors? <div class="text-center row"> <ul class="col-md-12 secondNav"> <li class="navbar-brand nav-item" style="margin-right: 9%"> <a href="#" >& ...

Trigger the callback function once the datatables DOM element has finished loading entirely

Hello there! I have a question regarding datatables. Is there any callback function available that is triggered after the datatables DOM element has finished loading? I am aware of the callbacks fnInitComplete, but they do not serve my purpose. Specificall ...

Utilizing Angular Forms for dynamic string validation with the *ngIf directive

I have a challenge where I need to hide forms in a list if they are empty. These forms contain string values. I attempted to use *ngIf but unfortunately, it did not work as expected and empty fields are still visible in the list. How can I address this iss ...

Optimal method for integrating Google Font in GWT application

After successfully installing the Roboto font on my machine, I proceeded to include it in my welcome.html file by adding the following code: <link href='http://fonts.googleapis.com/css?family=Roboto:regular,medium,bold,thin' rel='stylesh ...

What is the purpose of the tabindex in the MUI Modal component?

Struggling with integrating a modal into my project - it's refusing to close and taking up the entire screen height. On inspection, I found this troublesome code: [tabindex]: outline: none; height: 100% How can I remove height: 100% from the ...

Adjust the width of the button to best fit the content or label

Here we have a screenshot of HTML source code showing a button that is wider than the content it contains. The highlighted area in yellow indicates there is extra space at the right side of the button due to it being displayed on multiple lines. Is this be ...

Issue with Angular: RouterLinkActive fails to work properly with formControlName

I am currently working on a vertical navigation bar that allows the user to navigate to different components. However, I am facing an issue where when I click on a list item, it's supposed to be active but I have to click on it to navigate to the comp ...

The read more button is not functioning properly when used in conjunction with the <br>

Can someone help me debug an issue I'm facing with my code? I have created an HTML tab that contains multiple DOM elements, each with a "Read More" button. Everything works fine when it's just plain text, but as soon as I add tags within the p ...

Challenges arising from CSS position: fixed on iPhone 6+ in landscape orientation running iOS 9

Encountered a strange issue with the fixed header on my website under specific conditions: Using an iPhone 6+ in landscape mode. Using Safari with at least two tabs opened. The page has a fixed position header with html and body set to position: relative ...

I am attempting to separate this "for" loop in order to generate five distinct DIV elements

Hello there! I am a beginner and I am attempting to create 5 different players by using some code that I found. Here is the code I have been working with: https://codepen.io/katzkode/pen/ZbxYYG My goal is to divide the loop below into 5 separate divs for ...

Discover more in React about using ellipses (...) with dangerouslySetInnerHTML

What is the best method for limiting the number of HTML lines retrieved using dangerouslySetInnerHTML in a React application and creating a '... Read More' expander for it? I attempted to use react-lines-ellipsis, but unfortunately the 'tex ...

Interactive dropdown menu that scrolls upon clicking

Is there a way to make the page automatically scroll down to the bottom of a dropdown menu when it is clicked? Currently, users have to manually scroll down after opening the menu. I initially tried using anchors for this functionality, but it interfered w ...

Monochromatic CSS background transformation upon hovering

Looking for a solution with my CSS sprite setup: Here is the HTML: <a id="estates" href="http://www.domain.com/estate"></a> The corresponding CSS: #estates {background-position: -200px 0px;width: 96px;height: 90px;} #estates {background: u ...

Is there a way to achieve three distinct outlines on a circular div simultaneously?

Here is the code I have been working on. My goal is to apply three different levels of outlines to a single div element. I successfully added borders for the first level and shadows for the second. Is it possible to add a third level using only CSS? I kno ...

Improper Placement of Bootstrap 5 Modal

I seem to be facing an unexpected issue where the Bootstrap 5 Modal and other components are displaying inside the sidebar menu instead of the main content area. Has anyone encountered this problem before? How can it be resolved? Here is a test example: ...

Background image changing due to React re-render

I'm working on a React component that generates a random background image each time a user visits the page. However, I'm facing an issue where the background image updates every time a user types something into an input field. I've tried usi ...

What is the best way to switch back and forth between Bootstrap 5.1.0 modals?

I encountered an issue where the first modal remains visible when opening the second modal within the initial popup. Can anyone explain why this is happening? Furthermore, I noticed that the backdrop for the second modal is darker, indicating that it is s ...

Can you provide guidance on how to prioritize container div style over CSS class?

Here's the HTML code snippet I'm working with: <html> <head> <style> .text-box { color: red; } </style> </head> <body> <p class=&qu ...

How to style the background color of the selected option in a <select> element using

Is there a specific style I can use to change the color of a selected option in a dropdown menu? For example: <HTML> <BODY> <FORM NAME="form1"> <SELECT NAME="mySelect" SIZE="7" style="background-color:red;"> <OPTION>Test 1 &l ...

Unable to discover a method to accomplish this task

Greetings to the Stack Overflow community! I have a scenario with two div blocks containing images of dimensions 1280px width and 700px height each. In the first block, there is a div with a width of 400px and a height of 100% floating left. The second ...