【发布时间】:2017-10-03 23:11:45
【问题描述】:
我一直在寻找一些 Bootstrap 3 警报框从屏幕顶部飞入并在所有元素顶部的中心屏幕结束的示例。
我找到了很多。 modals,但我如何为警报框完成此行为?
【问题讨论】:
我一直在寻找一些 Bootstrap 3 警报框从屏幕顶部飞入并在所有元素顶部的中心屏幕结束的示例。
我找到了很多。 modals,但我如何为警报框完成此行为?
【问题讨论】:
你可以看一下由chipChocolate.py 提供的answer,以及他提供的小提琴here。 由于 div 是从下到上移动的,因此这并不完全是您正在寻找的东西,但想法是相同的。 创建三个 div:main-container、alert-container、alert-content
<div class="main-container">
<div class="alert-container">
<!-- placeholder image -->
<img class="inner_img" src="http://placehold.it/1000x1000" />
<div class="alert-content">
<div class="alert alert-danger">
<strong>Danger!</strong> This alert box could indicate a dangerous or potentially negative action.
</div>
</div>
</div>
</div>
然后应用这个 css
.main-container{
position: relative; /* Set to absolute */
}
.alert-container {
position: absolute; /* Set to absolute and positioned at top corner*/
top: 0;
left: 0;
}
.alert-content {
position: absolute; /* This moves it to the bottom (initial state) */
bottom: 90%;
width: 100%;
height: 10%;
transition: bottom 1s;
}
.main-container:hover .alert-content {
bottom: 50%; /* This moves it to the middle (only on hover) */
}
我用引导警报制作了一个小提琴here,并从页面顶部过渡到页面中间。你可以做相应的调整。
【讨论】: