图像#1:带 .in类的引导警报:
图像#2:没有 .in类的引导警报(隐藏下面的内容):
自从过去三个小时以来,我一直在努力让警报完美运行 - 而不会取代其他内容。我已经阅读了一些博客文章和SO Q& A但未能达到预期的效果。
尝试:
display: none;
有效取代内容。HTML:
<div class="alert alert-message alert-info fade"><p> Joined: StaticRoom </p></div>
JavaScript的:
function status(type, msg) {
var alertHTML = "<div class='alert alert-message alert-" + type + " fade'><p> " + msg + " </p></div>";
$("#roomInfo").html(alertHTML);
$(".alert-message").addClass("in");
setTimeout(function () {
$(".alert-message").removeClass("in");
}, 3000);
}
图片#3:渴望:
帮助!
答案 0 :(得分:2)
这是由提醒自我height
,padding
和margin
引起的。 .fade
类仅更改opacity
值,不再:
摘自bootstrap.css
.fade{
opacity:0;
-webkit-transition:opacity .15s linear;
transition:opacity .15s linear
}
.fade.in{
opacity:1
}
你可以做的是用:
覆盖Bootstrap CSS.fade {
height: 0;
padding: 0;
margin: 0;
-webkit-transition:height .15s linear;
transition:height .15s linear;
}
.fade.in {
height: auto;
padding: 15px;
margin-bottom: 20px;
}
Here is a working JSFiddle to show you the result.
修改强>
Updated fiddle to show you how to position your elements
编辑2
我没有得到你想要的绝对定位警报。因此,您不需要任何其他类,只需简单:
.movie {
position: relative;
width: 430px;
margin: 20px auto;
padding: 5px;
padding-bottom: 40px; /* give extra space for form */
}
.movie form {
position: absolute;
bottom: 0; left: 0; right: 0;
padding: 5px;
}
.movie .alert {
position: absolute;
bottom: 30px; left: 5px; right: 5px;
}