<div class="alert simple-alert">
<h3>Simple Alert Message</h3>
<a class="close">×</a>
</div>
<div class="alert success-alert">
<h3>Success Alert Message</h3>
<a class="close">×</a>
</div>
<div class="alert danger-alert">
<h3>Danger Alert Message</h3>
<a class="close">×</a>
</div>
<div class="alert warning-alert">
<h3>Warning Alert Message</h3>
<a class="close">×</a>
</div>
@import url('https://fonts.googleapis.com/css?family=Quicksand&display=swap');
*{
margin:0;
padding:0;
box-sizing:border-box;
}
h3{
font-family:Quicksand;
}
.alert{
width:50%;
margin:20px auto;
padding:30px;
position:relative;
border-radius:5px;
box-shadow:0 0 15px 5px #ccc;
}
.close{
position:absolute;
width:30px;
height:30px;
opacity:0.5;
border-width:1px;
border-style:solid;
border-radius:50%;
right:15px;
top:25px;
text-align:center;
font-size:1.6em;
cursor:pointer;
}
@mixin alert($name,$bgColor){
$accentColor:darken($bgColor,50);
.#{$name}{
background-color:#{$bgColor};
border-left:5px solid $accentColor;
.close{
border-color:$accentColor;
color:$accentColor;
}
}
}
@include alert(simple-alert,#ebebeb);
@include alert(success-alert,#a8f0c6);
@include alert(danger-alert,#f7a7a3);
@include alert(warning-alert,#ffd48a);
View Compiled
$(".close").click(function() {
$(this)
.parent(".alert")
.fadeOut();
});
This Pen doesn't use any external CSS resources.