0

我在我的 MVC 应用程序中使用引导警报。出现警报时,它会占用左边距,但在右侧它不会占用任何边距。

我没有对css进行任何修改,不确定它是否正确和默认边距。 在此处输入图像描述

这是我的代码:

<div class="alert alert-block alert-error">
    <button type="button" class="close" data-dismiss="alert">&times;</button>
    It is a test error message. It is test error message.
     It is a test error message. It is test error message.
     It is a test error message. It is test error message.
     It is a test error message. It is test error message.
     It is a test error message. It is test error message.

</div>

我试着把它放在一个 div 中并添加

我试过什么?

我尝试将此代码放入 div 并应用于.input-append外部 div。结果警报轻弹某个部分并自动隐藏并保留在屏幕上,如下所示:

在此处输入图像描述

我需要什么帮助?

您能否指导我如何使左右边距相等,引导程序中是否有默认类?

编辑 我知道我可以集中这个 div 我的fixing width设置margins:auto,但担心固定宽度是否会保持响应性,因为它是使用引导程序的基本目的?我不确定在修改哪些样式我应该修改哪些不应该修改。

4

3 回答 3

1

正确的代码是:

<div class="alert alert-block alert-danger alert-dismissable">
    <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
    It is a test error message. It is test error message.
    It is a test error message. It is test error message.
    It is a test error message. It is test error message.
    It is a test error message. It is test error message.
    It is a test error message. It is test error message.

</div>

边距/填充应用于父 div,而不是警报 div 本身

http://jsfiddle.net/N5aG5/1/

于 2013-10-29T00:33:44.650 回答
1

将整个 div 居中,这将自动提供右边距:

<div class="alert alert-block alert-error" style="width:800px margin: 0 auto;">

如果白色外框的宽度是 1000px,那么每边都有 100px 的边距

于 2013-10-28T23:58:05.857 回答
0

由于您使用的是 Bootstrap,您可以使用他们的网格系统来保持您的设计响应,例如:

<div class="alert alert-block alert-error col-xs-12 col-sm-6 col-sm-push-3">
    <button type="button" class="close" data-dismiss="alert">&times;</button>
    It is a test error message. It is test error message.
    ...
</div>

我还添加了类text-center以使它在短文本的情况下看起来更好。

于 2015-07-30T12:11:51.173 回答