小编str*_*e56的帖子

如何让Bootstrap Toasts不自动消失?

我有一个 Bootstrap 5 网站和一个显示访问者离线时间的 Toast。

\n

如果我离线,Toasts 会出现并自动消失。我希望它一直保留到访问者单击十字或连接恢复为止。我尝试添加data-autohide="false"我的代码,但它不起作用。如何确保 Toast 不会在没有操作的情况下自动关闭?

\n

如果我测试实时版本,Toasts 会完全消失:

\n

https://getbootstrap.com/docs/5.0/components/toasts/#live

\n

索引.html:

\n
<!doctype html>\n<html lang="fr" class="h-100">\n\n  <head>\n    <meta charset="utf-8">\n    <meta name="viewport" content="width=device-width, initial-scale=1">\n  </head>\n\n  <body class="position-relative d-flex flex-column bg-dark text-white text-center" data-bs-spy="scroll" data-target="#navbar" data-bs-offset="85" tabindex="0">\n\n    <div class="toast-container position-fixed bottom-0 start-50 translate-middle-x mb-3">\n      <div id="updateToast" class="toast d-none" role="alert" aria-live="assertive" aria-atomic="true">\n        <div class="toast-header">\n          <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" class="bi bi-arrow-repeat text-success" viewBox="0 0 16 16">\n            <path d="M11.534 7h3.932a.25.25 0 0 1 .192.41l-1.966 2.36a.25.25 0 …
Run Code Online (Sandbox Code Playgroud)

html javascript toast twitter-bootstrap bootstrap-4

6
推荐指数
1
解决办法
8633
查看次数

标签 统计

bootstrap-4 ×1

html ×1

javascript ×1

toast ×1

twitter-bootstrap ×1