Html Bootstrap CSS bg-success 警报不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22467967/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 01:16:28  来源:igfitidea点击:

Bootstrap CSS bg-success alert not working

htmlcsstwitter-bootstraptwitter-bootstrap-3

提问by chuckfinley

For some reason bg-danger class in Bootstrap 3 does not display red background. Why?

出于某种原因,Bootstrap 3 中的 bg-danger 类不显示红色背景。为什么?

<p class="bg-danger">There was an error updating your details.</p>

回答by martynas

In Bootstrap you have the following pre-defined backgrounds:

在 Bootstrap 中,您有以下预定义的背景:

Bootstrap 3.1.0:

引导程序 3.1.0:

<div class="bg-primary">...</div>
<div class="bg-success">...</div>
<div class="bg-info">...</div>
<div class="bg-warning">...</div>
<div class="bg-danger">...</div>

Bootstrap 3.0.3:

引导程序 3.0.3:

<div class="alert alert-success">...</div>
<div class="alert alert-info">...</div>
<div class="alert alert-warning">...</div>
<div class="alert alert-danger">...</div>

Bootstrap components

引导组件

View all Bootstrap components here

在此处查看所有 Bootstrap 组件

回答by Aleksander Bavdaz

Contextual backgrounds bg-primary, bg-success, bg-info, bg-warningand bg-dangerwere added to Bootstrap as of version 3.1.0 and were not present in 3.0.3 and before.

自 3.1.0 版起,上下文背景bg-primarybg-success、和已添加到 Bootstrap 中,但在 3.0.3 及之前版本中不存在。bg-infobg-warningbg-danger

There have however been alerts with the four contextual classes alert-success, alert-info, alert-warningand alert-dangerwhich are suitable for that kind of error messages.

然而,已经有alerts的四个上下文类alert-successalert-infoalert-warningalert-danger适合于那种错误信息。

<p class="alert alert-danger">There was an error updating your details.</p>

Also see the Bootstrap Alerts Component: http://getbootstrap.com/components/#alerts

另请参阅 Bootstrap 警报组件:http: //getbootstrap.com/components/#alerts

回答by felwithe

I just spent all day trying to figure out why alert-errorwasn't working, only to realize it's not alert-error, it's alert-danger. Leaving this here in case someone else tortures themselves for hours trying to figure out what's wrong with their Bootstrap 3 alert.

我只是花了一整天的时间试图找出为什么alert-error不起作用,才意识到这不是警报错误,而是警报危险。留在这里以防其他人折磨自己几个小时试图找出他们的 Bootstrap 3 警报有什么问题。