div.container
a
img(src='http://img.sc115.com/uploads/png/110125/201101251547085508.png')
div.popup
div.close.fa.fa-times
xxxxxxxxxx
body
background-color #f7eecd
.container
position absolute
transform translate(-50%,-50%)
top 50%
left 50%
a
img
width 256px
height 256px
transition width 0.5s, height 0.5s;
a:hover
img
width 300px
height 300px
.popup
width 240px
height 240px
background url('http://img.web07.cn/UpPic/Png/201404/28/5697280852151-lp.png')
display none
.close
position absolute
top 0
right 0
function isExist(elem){
if(typeof elem !== 'undefined' && typeof elem !== null) {
return true;
}else{
return false;
}
}
var addCover = function(){
removeCover();
var coverCss = {
position: 'fixed',
zIndex: '100',
top : '0px',
left: '0px',
bottom: '0px',
right: '0px',
backgroundColor:'#000',
opacity: 0.6
}
var cover = $('<div id="cover" class="mask"/>');
$('body').append(cover.css(coverCss));
}
var removeCover = function(){
if(isExist($('#cover'))) $('#cover').remove();
}
function popup(target){
addCover();
target.css('position','fixed')
.css("top",($(window).height()-target.height())/2)
.css("left",($(window).width()-target.width())/2)
.css("z-index","9999")
.fadeIn();
$(".close").on('click',function(){
removeCover();
target.fadeOut();
return false;
});
}
$('a').on('click',function(){
popup($('.popup'))
})