Bootstrap alert control

Alert control

Alert provides contextual feedback messages for typical user actions with the handful of available and flexible alert messages. For inline dismissal, use the alerts jQuery plugin.

Wrap any text and an optional dismiss button in .alert for a basic warning alert message.


<!DOCTYPE HTML>
<html>
<head>
<link href="http://java2s.com/style/bootstrap.min.css" rel="stylesheet">
<!--  w w  w  .  j a va  2  s.c  om-->
<script src="http://java2s.com/style/jquery-1.8.0.min.js"></script>
<script src="http://java2s.com/style/bootstrap.min.js"></script>

</head>
<body style='margin: 20px;'>

  <div class="alert">
    <button type="button" class="close" data-dismiss="alert">&times;</button>
    <strong>Warning!</strong> Best check yo self, you're not looking too
    good.
  </div>
</body>
</html>

Click to view the demo

The following code adds optional classes to change an alert's connotation. It uses danger class to mark an alert box.


<!DOCTYPE HTML>
<html>
<head>
<link href="http://java2s.com/style/bootstrap.min.css" rel="stylesheet">
<!--from  w w  w.  java 2  s .  c  om-->
<script src="http://java2s.com/style/jquery-1.8.0.min.js"></script>
<script src="http://java2s.com/style/bootstrap.min.js"></script>

</head>
<body style='margin: 20px;'>

  <div class="alert alert-danger">
    <button type="button" class="close" data-dismiss="alert">?</button>
    <strong>Oh snap!</strong> Change a few things up and try submitting
    again.
  </div>
</body>
</html>

Click to view the demo

Success alert


<!DOCTYPE HTML>
<html>
<head>
<link href="http://java2s.com/style/bootstrap.min.css" rel="stylesheet">
<!--  w  w w . j a v a  2 s  .  c o  m-->
<script src="http://java2s.com/style/jquery-1.8.0.min.js"></script>
<script src="http://java2s.com/style/bootstrap.min.js"></script>

</head>
<body style='margin: 20px;'>

  <div class="alert alert-success">
    <button type="button" class="close" data-dismiss="alert">?</button>
    <strong>Well done!</strong> You successfully read this important alert
    message.
  </div>
</body>
</html>

Click to view the demo

Information alert.


<!DOCTYPE HTML>
<html>
<head>
<link href="http://java2s.com/style/bootstrap.min.css" rel="stylesheet">
<!--from   w w  w  . ja  v a  2 s.c o m-->
<script src="http://java2s.com/style/jquery-1.8.0.min.js"></script>
<script src="http://java2s.com/style/bootstrap.min.js"></script>

</head>
<body style='margin: 20px;'>

  <div class="alert alert-info">
    <button type="button" class="close" data-dismiss="alert">?</button>
    <strong>Heads up!</strong> This alert needs your attention, but it's
    not super important.
  </div>
</body>
</html>

Click to view the demo

We can use the .alert-link utility class to quickly provide matching colored links within any alert.


<!DOCTYPE HTML>
<html>
<head>
<link href="http://java2s.com/style/bootstrap.min.css" rel="stylesheet">
<!--from  www .j  a v  a2s. c  o  m-->
<script src="http://java2s.com/style/jquery-1.8.0.min.js"></script>
<script src="http://java2s.com/style/bootstrap.min.js"></script>

</head>
<body style='margin: 20px;'>

  <div class="alert alert-danger">
    <button type="button" class="close" data-dismiss="alert">?</button>
    <strong>Oh snap!</strong> <a href="#" class="alert-link">Change a
      few things up</a> and try submitting again.
  </div>
</body>
</html>

Click to view the demo





















Home »
  Bootstrap »
    Example »




Accordion
Alert
Auto Complete
Badge
Breadcrum
Button
Carousel
Collapse
Dialog
Dropdown
Form
Icon
Jumbotron
Label
Layout
List
List Group
Media
Navigation Bar
Pager
Page Header
Panel
Paragraph
Pills
Popover
ProgressBar
ScrollSpy
Switch
Tab
Table
Thumnail
Tooltip
Tree
Well