Box Pesan

by Maz Soma

HTML

<button class='info'>Info</button>
<div class='box'>
  <div class='pesan'>
Selamat datang di Blog SMZ. Ini hanya contoh dialog box sederhana dengan jQuery. Untuk membuatnya, silahkan pahami sedikit demi sedikit, jangan terburu-buru.<br />
 <span class='ttd'></span>
  </div>
<div class='close'></div>
</div>

CSS

.info{
background-color: #1191Da;
color:white;
padding:1px 10px 6px 10px;
cursor:pointer;
font-size:12px;
font-weight:bold;
}
.box {
  width: 600px;
  height: 200px;
  background-color: #f72c2c;
  border-radius: 5px;
  position: absolute;
  left: 50%;
  margin-top: -150px;
  margin-left: -300px;
  top: -9999px;
  z-index: 1000;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.4) inset, 0 1px 0 rgba(255, 255, 255, 0.2);
}
.box .pesan {
  position: absolute;
  top: 30px;
  right: 10px;
  bottom: 10px;
  left: 10px;
  padding: 5px 10px;
  overflow: auto;
  background-color: #d33f04;
  color: #fff;
  text-align: left;
  line-height: 1.5em;
  font-size: 14px;
  border-radius: 0 0 5px 5px;
     box-shadow: 3px 4px 4px 5px #ef1818; 
}
.pesan .ttd:after {
  content: "Soma Anggoro";
  position: relative;
  float: right;
}
.close:after {
  content: url('http://2.bp.blogspot.com/-d-5BS0YCkho/UOKe2UIw0rI/AAAAAAAAC4w/md_iYNVHaHk/s1600/delete4.png');
  position: absolute;
  top: -10px;
  right: -10px;
  background: #d33f04;
  border-radius: 100%;
  padding: 10px;
  z-index: 1000;
  cursor: pointer;
}

JavaScript

//<![CDATA[
$(document).ready(function () {
//tampilkan kotak dialog saat muncul dengan class info
    $('.info').click(function () {
        $('.info').hide();
        $('.box').css({top: '50%',position: 'fixed'})
        $('body').css({background: '#123',transition: 'all 5s'}) //efect body berubah warna
    });
//sembunyikan kotak dialog dengan class close
    $('.close').click(function () {
        $('.box').hide()
        $('body').css({background: '#ecf0f1',transition: 'all 5s'}) //efect body berubah warna
    })
});
//]]>