JSFiddle - React, Tailwind, and code Playground

Alert Message (alertMsg)

by Jennifer Perrin

HTML

<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/font-awesome/2.0/css/font-awesome.css">
<div class="alertMsg primary">
    <span class="alertIcon"><i class="icon-bullhorn"></i></span>
    <a class="alertClose" href="#"><i class="icon-remove"></i></a>
    <div class="alertContent">
        <span class="alertTitle">Awesome</span>
        <div class="alertText">These Alerts are!</div>
    </div>
</div>

<div class="alertMsg info">
    <span class="alertIcon"><i class="icon-info-sign"></i></span>
    <a class="alertClose" href="#"><i class="icon-remove"></i></a>
    <div class="alertContent">
        <span class="alertTitle">Heads up!</span>
        <div class="alertText">This alert needs your attention, but it's not super important.</div>
    </div>
</div>

<div class="alertMsg success">
    <span class="alertIcon"><i class="icon-check"></i></span>
    <a class="alertClose" href="#"><i class="icon-remove"></i></a>
    <div class="alertContent">
        <span class="alertTitle">Well Done</span>
        <div class="alertText">You successfully read this important alert message.</div>
    </div>
</div>

<div class="alertMsg warning">
    <span class="alertIcon"><i class="icon-warning-sign"></i></span>
    <a class="alertClose" href="#"><i class="icon-remove"></i></a>
    <div class="alertContent">
        <span class="alertTitle">Warning</span>
        <div class="alertText">Best check yo self, you're not looking too good.</div>
    </div>
</div>

<div class="alertMsg danger">
    <span class="alertIcon"><i class="icon-remove-sign"></i></span>
    <a class="alertClose" href="#"><i class="icon-remove"></i></a>
    <div class="alertContent">
        <span class="alertTitle">Oh snap!</span>
        <div class="alertText">Change a few things up and try submitting again.</div>
    </div>
</div>

CSS

@import url(http://fonts.googleapis.com/css?family=Open+Sans);
body { margin: 50px; font-family: 'Open Sans'; }
    
.alertMsg {
    -moz-box-sizing: border-box;
    background-color: #dcdcdc;
    box-shadow: 3px 3px 3px rgba(0, 0, 0, 0.2);
    display: inline-block;
    float: left;
    min-height: 60px;
    position: relative;
    width: 100%;
    margin-bottom: 10px;
}

.alertMsg > .alertIcon {
    bottom: 0;
    display: inline-block;
    left: 0;
    overflow: hidden;
    position: absolute;
    text-align: center;
    top: 0;
    width: 80px;
}

.alertMsg > .alertIcon > i {
    color: #ffffff !important;
    display: inline-block;
    font-size: 36px;
    font-weight: normal;
    margin-top: 12px;
}

.alertMsg > .alertContent {
    -moz-box-sizing: border-box;
    background-color: #f0f0f0 !important;
    color: #666666 !important;
    display: inline-block;
    float: right;
    font-size: 90%;
    min-height: 60px;
    padding: 15px 20px;
    width: calc(100% - 80px);
}
.alertMsg > .alertContent > .alertTitle {
    display: inline-block;
    float: left;
    font-weight: bold;
    margin-bottom: 5px;
    width: 100%;
    text-transform: uppercase;
}

.alertMsg > .alertClose {
    color: rgba(0, 0, 0, 0.4);
    cursor: pointer;
    font-size: 16px;
    line-height: 16px;
    opacity: 0.6;
    position: absolute;
    right: 15px;
    text-decoration: none;
    top: 12px;
}
    .alertMsg > .alertClose:hover { opacity: 1; }

.alertMsg > .alertContent > .alertText {
    display: inline-block;
    float: left;
    width: 100%;
}

.alertMsg.primary {
    background-color: #5388b7;
    color: #ffffff;
}
.alertMsg.info {
    background-color: #6fb6f4;
    color: #ffffff;
}
.alertMsg.success {
    background-color: #1abd9c;
    color: #ffffff;
}
.alertMsg.warning {
    background-color: #fac13b;
    color: #ffffff;
}
.alertMsg.danger {
    background-color: #f5725a;
    color: #ffffff;
}

JavaScript

$('.alertMsg .alertClose').each(function() {
    $(this).click(function(e) {
        e.preventDefault();
        $(this).parent().fadeOut("slow", function() {
            $(this).remove();
        });
    });
});