Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Close button not appearing for Bootstrap alert

I have following html that uses bootstrap. It works for the most part - but close button is not appearing for the alert. What is the code I am missing here? Please note that I am new to Bootstrap - so, it may be something simple.

Fiddle: http://jsfiddle.net/LijoCheeran/vxbt960c/

Code

<!DOCTYPE html>
<html>
  <head>
    <title>Bootstrap 101 Template</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  </head>

<body>

    <h1>Hello, world!</h1>

<div class="alert alert-success">
  <strong>Success!</strong> Bootstrap applied to alert.
</div>


<div style = "padding: 10px 10px 10px;">
   <form class = "bs-example bs-example-form" role = "form">
      <div class = "input-group">
         <span class = "input-group-addon">$</span>
         <input type = "text" class = "form-control" placeholder = "Amount">
         <span class = "input-group-addon">.00</span>
      </div>
   </form>
</div>

<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>

<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

</body>

</html>
like image 392
LCJ Avatar asked Nov 13 '16 23:11

LCJ


2 Answers

you are missing this line in your code.

   <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>

eg:

    <div class="alert alert-success">
    <!-- you missed this line of code -->
      <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
      <strong>Success!</strong> Bootstrap applied to alert.
    </div>

Good Luck

like image 118
Sodhi saab Avatar answered Nov 11 '22 23:11

Sodhi saab


You're expected to provide the close button yourself. As in the examples, use something like:

<div class="alert alert-warning alert-dismissible" role="alert">
  <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  <strong>Warning!</strong> Better check yourself, you're not looking too good.
</div>
like image 28
Ouroborus Avatar answered Nov 11 '22 22:11

Ouroborus