Search Topic Here

Monday, 10 August 2015

Bootstrap Alerts




Bootstrap provides an easy way to create predefined alert messages:


Alerts are created with the .alert class, followed by one of the four contextual classes .alert-success, .alert-info, .alert-warning or .alert-danger:

Closing Alerts

To close the alert message, add class="close" and data-dismiss="alert" to a link or a button element:


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


Example


<!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>
  <p>The .fade and .in classes adds a fading effect when closing the alert message.</p>
  <div class="alert alert-success fade in">
    <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
    <strong>Success!</strong> This alert box for success
  </div>
  <div class="alert alert-info fade in">
    <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
    <strong>Info!</strong> This alert box for information
  </div>
  <div class="alert alert-warning fade in">
    <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
    <strong>Warning!</strong> This alert box for warning
  </div>
  <div class="alert alert-danger fade in">
    <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
    <strong>Danger!</strong> Danger
  </div>
</div>

</body>
</html>

OUTPUT:




Bootstrap Example

Alerts

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

× Success! This alert box for success
× Info! This alert box for information
× Warning! This alert box for warning
× Danger! Danger

No comments:

Post a Comment