更改错误消息的大小不起作用

时间:2014-06-17 10:10:10

标签: html css css3 twitter-bootstrap

我有以下错误消息,我想更改它的高度, 我尝试了以下(.css(“height:10px;”);)并且这不起作用,任何想法 缺少什么

$messages.html("<div class='alert alert-danger'><strong>Error : </strong>" + message + "<button type='button' class='close' aria-hidden='true'>&times;</button></div>").css("height:10px;");

3 个答案:

答案 0 :(得分:2)

这可以通过改变设置高度的代码

来实现
css("height","10px")

检查完整代码

 $messages.html("<div class='alert alert-danger'><strong>Error : </strong>" + message + "<button type='button' class='close' aria-hidden='true'>&times;</button></div>").css("height","10px");

但是如果你确定自己最初想要什么,那么你需要通过jquery来完成这项工作吗? 你也可以这样做。

$messages.html("<div class='alert alert-danger' style='height:10px;'><strong>Error : </strong>" + message + "<button type='button' class='close' aria-hidden='true'>&times;</button></div>");

答案 1 :(得分:1)

它假设是这样的

$messages.html("<div class='alert alert-danger'><strong>Error : </strong>" + message + "<button type='button' class='close' aria-hidden='true'>&times;</button></div>").css("height","10px");

答案 2 :(得分:0)

Twitter bootstrap 中的所有提示框都将使用alert class。这将设置所有警告框将使用的样式,但对于其他框,我们将只更改颜色以匹配场景。

.alert {
padding: 8px 35px 8px 14px;
margin-bottom: 18px;
color: #c09853;
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
background-color: #fcf8e3;
border: 1px solid #fbeed5;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
}

.alert-heading {
color: inherit;
}

.alert .close {
position: relative;
top: -2px;
right: -21px;
line-height: 18px;
}

调用这些的HTML非常简单,只需将CSS类添加到外部div或段落标记。

<div class="alert">Example of an alert box.</div>

成功

当用户成功完成任务时,将使用成功警告框,所有CSS都将覆盖标准警报框的颜色。

.alert-success {
color: #468847;
background-color: #dff0d8;
border-color: #d6e9c6;
}

使用此CSS类时,您需要同时使用alert CSS和alert-success CSS。

<div class="alert alert-success">Example of the successful alert box</div>

危险或错误

错误警告框的作用与仅用于更改背景和文字颜色的成功框相同。

.alert-danger,
.alert-error {
color: #b94a48;
background-color: #f2dede;
border-color: #eed3d7;
}

同样,您需要同时使用警报CSS和警报错误CSS。

信息

最后一种风格是信息风格,用于通过使用CSS类alert-info突出显示给用户的消息。

.alert-info {
color: #3a87ad;
background-color: #d9edf7;
border-color: #bce8f1;
}

样式块

除了不同的场景样式,Twitter引导程序还为您提供了额外的CSS类,以进一步设置警报框的样式。

添加一类alert-block,可以增加框的填充。

.alert-block {
padding-top: 14px;
padding-bottom: 14px;
}

下一个样式将减少警报块​​内段落标记的边距。

.alert-block &gt; p,
.alert-block &gt; ul {
margin-bottom: 0;
}

.alert-block p + p {
margin-top: 5px;
}

可以通过将alert-block CSS类添加到其中一个警告框来使用添加额外填充的HTML。

<div class="alert alert-information alert-block">
Example of the information alert box
</div>

这是您目前使用Twitter引导程序获得的所有警报框,您可以根据您的要求更改/修改警告框。这是许多人反复询问的基本信息。我希望这些信息可以帮助很多人。如果你认为这个答案在某个地方对你有用,不知何故......请注意 - 投票给这个答案。谢谢..;)