【问题标题】:How to make alerts overlap?如何使警报重叠?
【发布时间】:2013-07-15 08:01:29
【问题描述】:

回复:http://twitter.github.io/bootstrap/components.html#alerts

我想在我的页面顶部显示这些警报。但是,每当我这样做时,它都会将其下方的内容向下推。我不想那样。我希望它只是重叠(意思是,它出现在顶部,但顶部的内容不会被下推)。

我可能在给定时间显示多个这些警报。对于那些,我认为我需要将它们堆叠在每个警报之上(否则,用户将无法阅读它们)。

我该怎么做?首选仅 CSS 解决方案。如果绝对需要,可以使用非 TB、jQuery 解决方案。

【问题讨论】:

标签: jquery css twitter-bootstrap


【解决方案1】:

您可以将警报放在绝对定位的容器中,将它们从流中弹出:

.alerts {
  position: absolute;
  top: 30px;
  left: 20px;
  right: 20px;
}
<div class="main">
  <h1>Heading</h1>
  <p>
    Some content here...
  </p>
</div>
<!-- the order of elements is insignificant (you can swap the main 
     container and the alerts container and have the same result) -->
<div class="alerts">
  <div class="alert">alerting...</div>
  <div class="alert">alerting once more...</div>
</div>

这通过使用 Bootstrap 声明性组件(使用 CSS 挂钩)进行演示,但也可以使用 Bootstrap 命令式 API(通过 JavaScript 调用)。

这里有一个live demo on plunker 来说明这一点。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-23
    • 2020-01-20
    • 1970-01-01
    相关资源
    最近更新 更多