CSS 


.alert {
    padding: 20px;
    color: white;
    margin-bottom: 15px;
}

.alert-danger {
    background-color: #f44336;
}
.alert-success {
    background-color: #27ae60;
}
.alert-warning {
    background-color: #e67e22;
}
.alert-info {
    background-color: #2980b9;
}

.closebtn {
    margin-left: 15px;
    color: white;
    font-weight: bold;
    float: right;
    font-size: 22px;
    line-height: 20px;
    cursor: pointer;
    transition: 0.3s;
}

.closebtn:hover {
    color: black;
}


HTML

  	<div class="alert alert-danger">
  <span class="closebtn" onclick="this.parentElement.style.display='none';">&times;</span> 
  This is an alert box.
</div>
<div class="alert alert-success">
  <span class="closebtn" onclick="this.parentElement.style.display='none';">&times;</span> 
  This is an alert box.
</div>
<div class="alert alert-warning">
  <span class="closebtn" onclick="this.parentElement.style.display='none';">&times;</span> 
  This is an alert box.
</div>
<div class="alert alert-info">
  <span class="closebtn" onclick="this.parentElement.style.display='none';">&times;</span> 
  This is an alert box.
</div>