Ways to eliminate spacing underneath alerts in Bootstrap 5

Currently, I am working on Ruby On Rails and incorporating Bootstrap 5 into my .html.erb file.

I noticed that there is extra padding:

that includes additional padding

How can I achieve a similar result like this:

enter image description here

Here's the code snippet:

<div class="alert alert-primary">
  <%= link_to 'Sign in to your account', sign_in_path, class: 'sign-up-text' %>
</div>

Answer №1

To remove the bottom margin of .alert, simply apply .mb-0:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="37555858434443455647770219071905">[email protected]</a>/dist/css/bootstrap.css">


<div class="alert alert-primary">
  alert alert-primary
</div>
<div class="bg-success">
  other content
</div>

<div class="alert alert-primary mb-0">
  alert alert-primary mb-0
</div>
<div class="bg-success">
  other content
</div>

Answer №2

To remove gutters, simply add the g-0 class to your element. For further information, refer to the official documentation here

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

Tips for increasing the size of Material-ui Rating icons

I am currently utilizing npm to develop a widget. I aim to utilize the material-ui Rating component and have successfully integrated it. However, when I embed the widget on a webpage, the html font-size is set at 62.5%, causing the component to appear too ...

Please provide the text enclosed within the h1 tags

Is there a way to extract the content between <h2> </h2> tags in PHP or jQuery from each page and use it as the title of the pages to ensure uniqueness? Example: <section class="sub_header"> <h2>Contact</h2> < ...

What is the best method for web scraping from the NVIDIA website using Python?

My current setup involves the utilization of BeautifulSoup4 and requests for web scraping. from bs4 import BeautifulSoup import requests url_NVIDIAGEFORCE = f'https://shop.nvidia.com/de-de/geforce/store/gpu/?page=1&limit=9&locale=de-de&ca ...

The storage of HTML5 data is not being saved locally

<html> <head> <title></title> <style type="text/css"> body { font-family: tahoma; } h2 { font-weight: bold; border-bottom: 2px solid gray; margin-bottom: 10px; } #dat ...

How can I position 7 images absolutely within a specific div?

I've been working on a website where users can have their avatars displayed using a JS function that loads 7 different images onto the page. These images correspond to different elements such as skin base, hair, eyes, mouth, shirt, shoes, and pants, a ...

How can I programmatically define the earliest and latest selectable dates in a date picker within Angular 4?

I am currently working on a task to prevent users from selecting past dates on a date picker. I want to set the minimum date available on the date picker to the current date. Below is the code snippet I am using to achieve this: Component.html <input ...

Is it possible to trigger a Bootstrap 5.2 Popover within an "if" statement?

As part of my input validation process, I am utilizing popovers. However, I am struggling with the syntax to make it work as intended. https://jsbin.com/sufitelodo/1/edit?html,js,output The JSBin provided serves as the foundation for this issue. I am un ...

Using the box-sizing property to give two inline-block elements a width of 50% each

Within my parent div with a padding of 20px, I am trying to make two span tags each occupy 50% of the parent div's width and align on the same line. Despite using box-sizing: border-box, the issue persists. HTML <div> <span>foo</span ...

PHP create hyperlink only if it has not been already linked

Could someone help me with a question that is similar to this one: How to Emulate StackOverflow Auto-Link Behavior Nevertheless, I am facing an issue with mixed content containing links. URLs that are already within A tags <a href="http://stackoverflo ...

Different ways to style this form using only CSS

Consider the HTML code below: <form> <p> <label for="id_name">Name:</label> <input id="id_name" maxlength="40" name="name" type="text"> </p> <p> <label for="id_format">Fo ...

The issue with the datatable row button functionality is not functioning as expected within the

I am facing an issue with my Jade Template code where I am trying to trigger a JavaScript function when a button is clicked on each row. Despite following the documentation for DataTables and Jade, I am unable to figure out what mistake I am making. It see ...

typescript is failing to update CSSRule with the newly assigned background-color value

I am currently working on dynamically changing the CSS style (specifically background-color) for certain text on a webpage. To achieve this, I have been attempting to modify CSSRule by accessing the desired CSSRule based on selectedText. Here is the code s ...

The issue with CSS z-index not functioning properly when using absolute positioning

Here is the issue I'm facing: I have multiple div containers in my code. .outer { position: relative; z-index: 1; } .inner { position: absolute; z-index: 999; } <div class="outer"> <div class="inner"> <div class="option ...

What is the best way to restrict users from accessing more than 5 Bootstrap Tab-Panes at once?

Users are restricted to opening only a maximum of 5 tab panes, even if there are multiple tab buttons available. If the user tries to click on the 6th tab, an alert message will be displayed. function addTab(title, url){ var tabs=$(".tabs"), tab ...

A guide on implementing a Material UI table to display one row at a time on each page

I'm currently working on incorporating a Material UI table to showcase content with just one row per page. After successfully loading the page and displaying the first row, I encountered an issue where navigating to subsequent pages does not render a ...

Instructions on creating a countdown timer that reveals a hidden div once it reaches zero, remains visible for a set period, and then resets

I created a countdown timer that displays a div when the timer reaches zero. However, I am struggling with getting the timer to reset and start counting down again after displaying the div. For instance, if I set the timer for 7 days and it reaches the de ...

How can a CSS class be inherited from a different file?

I have defined a class for styling a button: .client-header button { /*Properties*/ } And I also have a class to indicate when the menu is open: .client-menu-open { /*Properties*/ } My goal is to change the background of the button depending on ...

attribute alternativeType

<input type="text" name="date" value="" data-type="datetime" required="true" /> I'm looking for a different approach than using dojoType for a couple of reasons: The parseonload behavior causes the page to "jump" when loading (system-defaul ...

Pager made the bold decision to transition from a horizontal layout to a vertical format

I've been feeling frustrated lately. After being sick for a while, my customer called to inform me that the gallery pager on their website is broken. Although I managed to fix most of it and restore the original style, I'm struggling to get it t ...

Fundamental CSS Selector

I'm encountering an issue with CSS selectors while using Foundation 5: I am having trouble selecting the desired element, which seems strange to me. The specific problem I am facing is related to changing the background-color of the "Right Button Act ...