2013-06-12 22 views
0

我有以下的CSS:JQuery的DIV弹出,同时使网页调光器

.faq { 
    position: absolute; 
    border: 3px double #078800; 
    background: #ECFFEB; 
    left: 480px; 
    width: 550px; 
    z-index: 99999; 
} 
#showFAQ { 
    cursor: pointer; 
    color: #018125; 
} 

JQuery的:

$(document).ready(function(){ 
    $('#showFAQ').click(function(){ 
     $('.faq').show().css("top", "400px").animate({top: 1150}, 300); 
    }); 

    $('.sButton').click(function(){ 
     $('.faq').fadeOut('slow'); 
    }); 
}); 

HTML:

<span id="showFAQ">FAQ</span> 

... 

<div class=faq style='display: none'> 
    <table border=0 cellPadding=8 cellSpacing=8 width=100%> 
     <tr> 
      <td colSpan=2 align=center style="font-family: Verdana, Arial; color: #078800; font-weight: bold; font-size: 18px;">Frequently Aasked Questions</td> 
     </tr> 
     <tr> 
      <td>1. Do I have to complete the entire "Your Information" section?</td> 
     </tr> 
     <tr> 
      <td style="padding-left:50px;">Yes, all information inside the "Your Information" is required to successfully complete the exam. Failure to do so will result in having to retake the exam from scratch.</td> 
     </tr> 
     <tr> 
      <td>2. What if my browser crashes or the page exits and I was in the middle of the exam?</td> 
     </tr> 
     <tr> 
      <td style="padding-left:50px;">Unfortunately, at this time there is no way to save the session. You will have to retake the exam from the start. We are working on fixing that and will update everyone on when it goes in effect.</td> 
     </tr> 
     <tr> 
      <td>3. Can I retake the exam multiple times?</td> 
     </tr> 
     <tr> 
      <td style="padding-left:50px;">Yes, but only the first one will count. If for any reason, you needed to take it more than once, please email HR and let them know why and they will reach out to you to with resolution.</td> 
     </tr> 
     <tr> 
      <td>4. I pressed the "Submit Answers" button and now the button shows "Processing..." but I can't press it anymore?</td> 
     </tr> 
     <tr> 
      <td style="padding-left:50px;">There is an error control put in place to ensure every question is answered before submitting the exam. Please ensure all questions have been answered and then the "Processing..." button will change back to "Submit Answers" which is clickable.</td> 
     </tr> 
     <tr> 
      <td>5. I did everything as per instruction, but I can't still submit the exam.</td> 
     </tr> 
     <tr> 
      <td style="padding-left:50px;">Please reach out to our Helpdesk at x2000 for further troubleshooting steps to assist in completing the exam.</td> 
     </tr> 
     <tr> 
      <td colSpan=2 align=center><input class=sButton type=button value="Close Window" /></td> 
     </tr> 
    </table> 
</div> 

我所希望做的是一次出现弹出窗口,我希望整个页面变暗,以便弹出窗口获得用户的注意。我知道那里还有其他人,但我决定自己做,而不需要太多编码。

我想用下面的图像,其具有45%的不透明度: Fade BG

我想用重复-X把图像和重复y以覆盖整个页面正下方的弹出,使用户可以仍然看到页面,但弹出窗口突出。一旦我关闭弹出窗口,我希望图像淡出以显示网页。

+2

的z-index:909090909090909090909090909090; ?!?!?!?!?!?最大值可能是有符号的32位值(-2147483648到+2147483647) – dezman

+0

那么它只用于测试... – Si8

+0

@watson是啊哈哈wut ....对于OP,只是有一个div在你的身体与巨大的大小相对位置和弹出的内部绝对位置或您喜欢的任何位置。当Z-index可见时将它的Z-索引设置为999,当它隐藏时则将其设为-999。不要玩90909090909 .........并提供小提琴PLZ :) – TecHunter

回答

1

你刚才创建模式“底层”为您答疑解惑,DIV,像这样:

http://jsfiddle.net/P2BfF/1/

<div class="modal" style="display:none;"></div> 

.modal { 
    width: 100000px; 
    height: 100000px; 
    background-color: #ccc; 
    position:absolute; 
    opacity: 0.2; 
    overflow:hidden; 
} 

注:我设置宽度和高度非常高,因为你有帮助弹出动画的位置。

,那么你在JS添加到您的切换:

$(document).ready(function(){ 
    $('#showFAQ').click(function(){ 
     $('.modal').show(); 
     $('.faq').show().css("top", "400px").animate({top: 1150}, 300); 
    }); 

    $('.sButton').click(function(){ 
     $('.faq').fadeOut('slow'); 
     $('.modal').hide(); 
    }); 
}); 
+0

如何将.CSS()更改为页面中心? – Si8

+0

你的意思是,你如何获得常见问题弹出窗口以页面为中心? –

+0

看看这个链接:http://jsfiddle.net/P2BfF/2/,我已经删除了div.modal并添加了一个box-shadow到你的faq容器。它有一个巨大的传播给你的衬底效应。此外,我将faq css上的左右边距设置为25%,以便为您居中。您可能需要稍微调整一下,但有一般的功能适合您。 –

3

创建一个全屏窗口的大小,设计你想要的样式。给它一个比你的页面更大的z-index。用弹出窗口创建一个新的div,并为它指定一个大于你的毯子的z-index。

#blanket { 
    z-index:1000; 
    position:fixed; 
    top:0; 
    left:0; 
    width:100%; 
    height:100%; 
    opacity:0.45; 
/* Other styling here */ 
} 
#popup { 
    z-index:1001; 
/* other styling here */ 
} 
+0

添加背景图片:url(myopactiybackground.png); ?我应该设置#blanket来显示:无? – Si8

+0

毯子可以根据需要打开和关闭。显示:none最初将隐藏它。使用$('#blanket').show()或类似的方法打开它。 – 2013-06-12 22:17:48