jQuery弹出背景颜色

时间:2012-10-18 19:58:08

标签: jquery html css

https://docs.google.com/document/d/1b2PZ-sGfikUnfXS3EB_8dw0HnmHUompYCvRyS2pKja8/edit

我附上了弹出窗口的截图... 如何让背景颜色变灰... 弹出窗口后面的区域 http://jsfiddle.net/nVZEB/19/

我正在为下面的弹出窗口提供jquery代码

$(function() {

var popup = false;

$(".open").click(function(){
    if(popup === false){
        $("#overlayEffect").fadeIn("slow");
        $(this).parent().find('.popupContainer').fadeIn("slow");
        $(this).parent().find('.close').fadeIn("slow");
        center();
        popup = true;
    }    
    });

    $(".close").click(function(){
        hidePopup();
    });

    $(".overlayEffect").click(function(){
        hidePopup();
    });

function center(){
    var windowWidth = document.documentElement.clientWidth;
    var windowHeight = document.documentElement.clientHeight;
    var popupHeight = $(".popupContainer").height();
    var popupWidth = $(".popupContainer").width();
    $(".popupContainer").css({
        "position": "absolute",
        "top": 85,
        "left": windowWidth/2-popupWidth/2
    });

    }
function hidePopup(){
    if(popup===true){
        $(".overlayEffect").fadeOut("slow");
        $(".popupContainer").fadeOut("slow");
        $(".close").fadeOut("slow");
        popup = false;
    }
}

} ,jQuery);

1 个答案:

答案 0 :(得分:0)

添加CSS .popupContainer { background-color: #333333; }就可以了。另外,我建议更好地格式化/解释你的问题。