<div class="wrapper">
<h1>Simple css Alerts</h1>
<div class="alert">Hi! I'm simple alert! Check how I look :)</div>
<div class="alert alert--primary">Hi! I'm simple alert! Check how I look :)</div>
<div class="alert alert--warning">Hi! I'm simple alert! Check how I look :)</div>
<div class="alert alert--danger">Hi! I'm simple alert! Check how I look :)</div>
<div class="alert alert--success">Hi! I'm simple alert! Check how I look :)</div>
</div>
$primary: #3498db;
$default: #34495e;
$warning: #e67e22;
$danger: #e74c3c;
$success: #2ecc71;
@mixin alertCreator($color) {
padding: 15px 30px;
margin-bottom: 15px;
border-radius: 3px;
border-bottom: 3px solid darken($color, 10%);
letter-spacing: 0.5px;
color: rgba(#fff, .8);
background-image: linear-gradient(lighten($color, 15%), $color);
box-shadow: 0 5px 10px rgba(#000, .3);
}
* {
box-sizing: border-box;
}
/*
** just for example
*/
h1 {
margin-bottom: 2rem;
text-transform: uppercase;
color: $default;
}
.wrapper {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
min-height: 100vh;
padding: 30px;
}
/*
** Alert styles
** also we can use @each or some one else for generating this alert, but this solution looks simpler :)
*/
.alert {
@include alertCreator($default);
}
.alert--primary {
@include alertCreator($primary);
}
.alert--warning {
@include alertCreator($warning);
}
.alert--danger {
@include alertCreator($danger);
}
.alert--success {
@include alertCreator($success);
}
View Compiled
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.