2014-11-06 2 views
0

Привет, друзья. Я просто пытаюсь добавить всплывающее окно facebook как блог блогера, поэтому у меня есть одна проблема. я хочу всплывающее окно появится центр веб-страницы с позиции absolute..below это код, который я использую .. заранее спасибо ..Как выровнять всплывающее окно окна

<style type='text/css'> 
#exepopup { 
    background-color: none; 
    position:absolute; 
    z-index: 9999; 
    display: none; 
    padding: 0px; 
    border: 10px solid rgba(82, 82, 82, 0.7); 
    -webkit-background-clip: padding-box; 
/* for Safari */ 
    background-clip: padding-box; 
/* for IE9+, Firefox 4+, Opera, Chrome */ 
    -webkit-border-radius: 8px 8px 8px 8px; 
    -moz-border-radius: 8px 8px 8px 8px; 
    border-radius: 8px 8px 8px 8px; 
    width: 40%; 
    height: 50%; 
    overflow: auto; 
    /* Recommended in case content is larger than the container */ 

    margin: auto; 
    /* Center the item vertically &amp; horizontally */ 
    /* Break it out of the regular flow */ 

    top: 0; 
    left: 0; 
    bottom: 0; 
    right: 0; 
    /* Set the bounds in which to center it, relative to its parent/container */ 
} 

#exepopup span { 
    font-size: 12px !important; 
    font-weight: normal !important; 
} 

#exepopup h1 { 
    background: #6d84b4 url(http://4.bp.blogspot.com/-wbOyGFuANTQ/UVF1F4ouC4I/AAAAAAAABiA/RX4jNlICbjM/s1600/aktechz-fb-lock.png) 98% no-repeat; 
    border: 1px solid #3b5998 !important; 
    color: #FFFFFF !important; 
    font-size: 20px !important; 
    font-weight: 700 !important; 
    padding: 5px !important; 
    margin: 0 !important; 
    font-family: arial !important; 
    overflow: hidden !important; 
} 

.exepopupdata { 
    font-size: 12px !important; 
    font-weight: normal !important; 
    height: 275px !important; 
    padding: 1px !important; 
    background: #fff !important; 
    border-bottom: 2px solid #ddd; 
    overflow: show !important; 
} 

#exepopupfooter { 
    text-align: left; 
    font-size:12px; 
    background: #F2F2F2 !important; 
    height: auto !important; 
    padding: 10px 10px 10px 10px !important; 
    overflow: hidden !important; 
} 

#exepopupclose { 
    float: right; 
    background-color: none !important; 
    border: 0px solid #ccc !important; 
    color: #111 !important; 
    font-weight: normal !important; 
    padding: 5px 8px 5px 8px !important; 
    text-decoration: none !important; 
    display: inline-block !important; 
    font-family: arial !important; 
    outline: none !important; 
    font-size: 12px !important; 
    margin: 0px !important; 
} 

#exepopupclose:active { 
    top: 0; 
    left: 0; 
}</style> 
<script type='text/javascript'> 
jQuery(document).ready(function() { 
function exepopupfunc() { 
var sec = 60 
var timer = setInterval(function() { 
$("#exepopupfooter span").text(sec--); 
if (sec == 0) { 
$("#exepopup").fadeOut("slow"); 
clearInterval(timer); 
} 
},1000); 
var exepopupwindow = jQuery(window).height(); 
var exepopupdiv = jQuery("#exepopup").height(); 
var exepopuptop = jQuery(window).scrollTop()+50; 
jQuery("#exepopup").css({"top":exepopuptop});} 
jQuery(window).fadeIn(exepopupfunc).resize(exepopupfunc) 
//alert(jQuery.cookie('sreqshown')); 
//var exepopupww = jQuery(window).width(); 
//var exepopupwww = jQuery("#exepopup").width(); 
//var exepopupleft = (exepopupww-exepopupwww)/2; 
var exepopupleft = 500; 
//var exepopupwindow = jQuery(window).height(); 
//var exepopupdiv = jQuery("#exepopup").height(); 
//var exepopuptop = (jQuery(window).scrollTop()+exepopupwindow-exepopupdiv)/2; 
jQuery("#exepopup").animate({opacity: "1", left: "0" , left: exepopupleft}, 0).show(); 
jQuery("#exepopupclose").click(function() { 
jQuery("#exepopup").animate({opacity: "0", left: "-5000000"}, 1000).show();});}); 
</script> 
<div id="exepopup"> 
<h1>Join Us On Facebook</h1> 
<div class="exepopupdata"><center><iframe src="http://facebook.com/plugins/likebox.php?href=https%3A%2F%2Fwww.facebook.com%2FEXEIdeas2010&amp;width=400&amp;colorscheme=light&amp;show_faces=true&amp;border_color=%23fff&amp;stream=false&amp;header=false&amp;height=260" scrolling="no" frameborder="0" style="border:none; overflow:show; width:400px; height:250px;" allowtransparency="true"></iframe></center></div> 
<div id="exepopupfooter">Please Wait <span>20</span> Seconds<a href="#" id="exepopupclose" onclick="return false;">Close X</a></div></div> 

ответ

0

Вы можете создать простую функцию изменения размера, как это :

function resize(popup) { 
    var y = $(window).scrollTop(); 
    var winH = $(window).height(); 
    var winW = $(window).width(); 
    popup.css('top', y + 20); 
    popup.css('left', winW/2-popup.width()/2); 
} 

Вы должны также вызывать функции выше, когда все окна браузера изменяет размер:

$(document).ready(function() { 
    $(window).resize(function() { 
    resize($('#popupexe')); 
    }); 
}); 
0

просто удалить этот CSS стиль для #exepopup:

bottom: 0; 
right: 0; 
0

Работающий JSFIDDLE пример:

http://jsfiddle.net/fixit/u8tbhhse/

Использование стиля - absolute с left: 50% элемента и установить его в середине по margin-left:-[half of the element size]

+0

Здравствуйте, сэр, спасибо за ваш ценный ответ. ase сказать еще одно, как отключить всплывающее окно на мобильном устройстве ... с помощью jquery или чего-нибудь еще. –

+0

Вы можете проверить, мобильное устройство и не отображать всплывающее окно; Ответ для проверки устройства: http://stackoverflow.com/questions/3514784/what-is-the-best-way-to-detect-a-handheld-device-in-jquery Пример: $ .browser .device = (/ android | webos | iphone | ipad | ipod | blackberry | iemobile | opera mini/i.test (navigator.userAgent.toLowerCase())); –

Смежные вопросы