位置错误消息(警报)在右下角使用Bootstrap和CSS

发布于 2025-01-29 18:40:34 字数 674 浏览 0 评论 0原文

我正在尝试显示一些错误消息,假设

<div class="alert alert-danger alert-dismissible fade show col-12" role="alert">
        This is an error
        <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
    </div>
<div class="alert alert-danger alert-dismissible fade show col-12" role="alert">
        This is an error
        <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
    </div>

使用HTML,CSS,Bootstrap堆叠在屏幕右下角 就像这样右下角的消息的图像

I'm trying to show some error messages, let's say

<div class="alert alert-danger alert-dismissible fade show col-12" role="alert">
        This is an error
        <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
    </div>
<div class="alert alert-danger alert-dismissible fade show col-12" role="alert">
        This is an error
        <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
    </div>

Stacked in the bottom right corner of the screen, using HTML, CSS, Bootstrap
Just like thisImage of messages in the bottom right corner

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凑诗 2025-02-05 18:40:34

您可以创建一个错误包装器div并将其定位为绝对。
例如。

.error-container{
  position:absolute;
  bottom:0;
  right:20px;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.0.2/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
 <div class="error-container">
    <div class="alert alert-danger alert-dismissible fade show " role="alert">
      This is an error 1
      <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
    </div>
<div class="alert alert-danger alert-dismissible fade show " role="alert">
  This is an error 2
  <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
  </div>
</div>

You can create an error wrapper div and position it absolute.
eg.

.error-container{
  position:absolute;
  bottom:0;
  right:20px;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.0.2/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
 <div class="error-container">
    <div class="alert alert-danger alert-dismissible fade show " role="alert">
      This is an error 1
      <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
    </div>
<div class="alert alert-danger alert-dismissible fade show " role="alert">
  This is an error 2
  <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
  </div>
</div>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文