te')); return $arr; } /* 遍历用户所有主题 * @param $uid 用户ID * @param int $page 页数 * @param int $pagesize 每页记录条数 * @param bool $desc 排序方式 TRUE降序 FALSE升序 * @param string $key 返回的数组用那一列的值作为 key * @param array $col 查询哪些列 */ function thread_tid_find_by_uid($uid, $page = 1, $pagesize = 1000, $desc = TRUE, $key = 'tid', $col = array()) { if (empty($uid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('uid' => $uid), array('tid' => $orderby), $page, $pagesize, $key, $col); return $arr; } // 遍历栏目下tid 支持数组 $fid = array(1,2,3) function thread_tid_find_by_fid($fid, $page = 1, $pagesize = 1000, $desc = TRUE) { if (empty($fid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('fid' => $fid), array('tid' => $orderby), $page, $pagesize, 'tid', array('tid', 'verify_date')); return $arr; } function thread_tid_delete($tid) { if (empty($tid)) return FALSE; $r = thread_tid__delete(array('tid' => $tid)); return $r; } function thread_tid_count() { $n = thread_tid__count(); return $n; } // 统计用户主题数 大数量下严谨使用非主键统计 function thread_uid_count($uid) { $n = thread_tid__count(array('uid' => $uid)); return $n; } // 统计栏目主题数 大数量下严谨使用非主键统计 function thread_fid_count($fid) { $n = thread_tid__count(array('fid' => $fid)); return $n; } ?>javascript - how to make popup in center of screen and overlaybackground to full screen high - Stack Overflow
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - how to make popup in center of screen and overlaybackground to full screen high - Stack Overflow

programmeradmin1浏览0评论

I am working on asp page. In master page I have a div like this:

<body id="page1" >
    <form id="form2" runat="server">
        <div id="content">
            <!-- this is popup light grey show -->
            <div class="darkenBg" id="popupBackground" style="display:none;"></div>

            <!-- content -->

            <div class="greenBox2 popUpWin" id="panySigninPopup" style="display:none;">
                <div class="topWrap">
                    <!-- popup window -->
                </div>
                <div class="botWrap">
                    <div class="corner-bottom-left">&nbsp;</div>
                    <div class="border-bottom">&nbsp;</div>
                    <div class="corner-bottom-right">&nbsp;</div>
                </div>
            </div>
        </div>
    </div>
</div>

I am showing it like this:

function ShowHomePagePopup(popupId) {
    $("#" + popupId).show();
    $("#popupBackground").show();
    $('#popupBackground').height(800);
    $("#page1").addClass('hideScrollbars');
}

css is like this:

html, body {
    height:100%;
    margin:0px;
}
.darkenBg { /*added this div after body*/
    background: url(/images/blackBg.png);
    position:absolute;
    z-index:30;
    width:100%;
    height:100%;
    bottom:0px;
}
.popUpWin {
    position:absolute;
    z-index:31;
    width:500px;
    left:50%;
    margin:200px 0 0 -250px
}
.hideScrollbars {
    overflow: hidden;
}
#content {
    background:url(/images/bg.gif) top left repeat-x #fff;
    overflow:hidden;
    padding-bottom:20px;
}
  1. When the popup appears, it is centered horizontally, but vertically at the top, so it is at top mid of the screen.
  2. The overlay, light grey background, means popupBackground is only 10% of the height of screen although width is 100%. How can I make it 100% high ?

I am working on asp page. In master page I have a div like this:

<body id="page1" >
    <form id="form2" runat="server">
        <div id="content">
            <!-- this is popup light grey show -->
            <div class="darkenBg" id="popupBackground" style="display:none;"></div>

            <!-- content -->

            <div class="greenBox2 popUpWin" id="panySigninPopup" style="display:none;">
                <div class="topWrap">
                    <!-- popup window -->
                </div>
                <div class="botWrap">
                    <div class="corner-bottom-left">&nbsp;</div>
                    <div class="border-bottom">&nbsp;</div>
                    <div class="corner-bottom-right">&nbsp;</div>
                </div>
            </div>
        </div>
    </div>
</div>

I am showing it like this:

function ShowHomePagePopup(popupId) {
    $("#" + popupId).show();
    $("#popupBackground").show();
    $('#popupBackground').height(800);
    $("#page1").addClass('hideScrollbars');
}

css is like this:

html, body {
    height:100%;
    margin:0px;
}
.darkenBg { /*added this div after body*/
    background: url(/images/blackBg.png);
    position:absolute;
    z-index:30;
    width:100%;
    height:100%;
    bottom:0px;
}
.popUpWin {
    position:absolute;
    z-index:31;
    width:500px;
    left:50%;
    margin:200px 0 0 -250px
}
.hideScrollbars {
    overflow: hidden;
}
#content {
    background:url(/images/bg.gif) top left repeat-x #fff;
    overflow:hidden;
    padding-bottom:20px;
}
  1. When the popup appears, it is centered horizontally, but vertically at the top, so it is at top mid of the screen.
  2. The overlay, light grey background, means popupBackground is only 10% of the height of screen although width is 100%. How can I make it 100% high ?
Share Improve this question edited Apr 3, 2014 at 11:43 ndsmyter 6,6153 gold badges23 silver badges37 bronze badges asked Aug 22, 2013 at 6:14 DotnetSparrowDotnetSparrow 28k63 gold badges186 silver badges318 bronze badges 5
  • 1 jqueryui./dialog --> modal dialog – Tushar Gupta - curioustushar Commented Aug 22, 2013 at 6:15
  • I can not use jquery ui dialog because i have my custom design of popup although I am using jquery to show my custom popup with .show method. – DotnetSparrow Commented Aug 22, 2013 at 6:19
  • @DotnetSparrow - Please see this solution – Sunil Kumar Commented Aug 22, 2013 at 6:24
  • How can I make overlay height 100% ? – DotnetSparrow Commented Aug 22, 2013 at 6:28
  • Sorry for the previous post. I just fix my answer. Hope it will help you! – leoMestizo Commented Aug 22, 2013 at 15:44
Add a ment  | 

3 Answers 3

Reset to default 8

This is a good way to make a popup only with CSS:

The HTML code:

<div class="container-popup">
    <div class="popup"></div>
</div>

The CSS code:

.container-popup {
    position: relative;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: rgba(0,0,0,.8);
}

.popup {
    width: 50%;
    height: 50%;
    background: #1abcb9;
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    margin: auto;
}

Check this Fiddle.

There is an example to simplest overlay popup

LINK

$(document).ready(function(){
  $(".container-popup, #close").click(function(){
   $('.popup').hide(); $('.container-popup').hide();
  });
});

Place the Popup Window inside the overlay-div!

 <body id="page1" style="height: 100%;">

<form id="form2" runat="server" style="min-height: 100%;">
 <div id="content">
..

content

...


</div>
</div>

<div class="darkenBg" id="popupBackground" style="display:none;">
        <div class="greenBox2 popUpWin" id="panySigninPopup" style="display:none;">
           <div class="topWrap">
          popup window
           </div>
           <div class="botWrap">
           <div class="corner-bottom-left">&nbsp;</div>
           <div class="border-bottom">&nbsp;</div>
           <div class="corner-bottom-right">&nbsp;</div>
        </div>
      </div>
    </div>
 </form>
</div>
发布评论

评论列表(0)

  1. 暂无评论