Bootstrap Alerts

The a element with class=”close” and data-dismiss=”alert” is used to close the alert box.

The .fade and .in classes adds a fading effect when closing the alert message.

Sample Code:

<!DOCTYPE html>
<html lang=”en”>
<head>
  <title>Bootstrap Example</title>
  <meta charset=”utf-8″>
  <meta name=”viewport” content=”width=device-width, initial-scale=1″>
  <link rel=”stylesheet” href=”http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css”>
  <script src=”https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js”></script>
  <script src=”http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js”></script>
</head>
<body>


<div class=”container”>
  <h2>Alerts</h2>
  <div class=”alert alert-success fade in”>
    <a href=”#” class=”close” data-dismiss=”alert” aria-label=”close”>&times;</a>
    <strong>Success!</strong>
  </div>
  <div class=”alert alert-info fade in”>
    <a href=”#” class=”close” data-dismiss=”alert” aria-label=”close”>&times;</a>
    <strong>Info!</strong>
  </div>
  <div class=”alert alert-warning fade in”>
    <a href=”#” class=”close” data-dismiss=”alert” aria-label=”close”>&times;</a>
    <strong>Warning!</strong>
  </div>
  <div class=”alert alert-danger fade in”>
    <a href=”#” class=”close” data-dismiss=”alert” aria-label=”close”>&times;</a>
    <strong>Danger!</strong>
  </div>
</div>


</body>
</html>

Output:




Cheers!!!

Leave a Reply