简体   繁体   中英

How to make popup box appear on top of body and not above body

I have a popup box appears on the homepage.But the problem is ,it appears above the body or header,wherever I placed in the template. But I want it to display with transparents background,overlaying the content.Thats how popup box works normally. But how do I achieve that please?

home.tpl(This is where I play around placing the popup box)

<!DOCTYPE html>
<html class="no-js" lang="en">
<head>
<?php include($data['config']['THEME_DIR_INC'].'inc/meta_common.inc.php'); ?>
<title>
<?php include($data['config']['THEME_DIR_INC'].'inc/title.inc.php'); ?>
</title>
<?php include($data['config']['THEME_DIR_INC'].'inc/scripts_common.inc.php'); ?>
</head>
<body>

<div id="wrapper">
  <?php include($data['config']['THEME_DIR_INC'].'inc/header.inc.php'); ?>
  <?php #include($data['config']['THEME_DIR_INC'].'inc/nav_main.inc.php'); ?>
     <div id="position_scroll">

      </div>
    <div id="boxes">
 <?php include($data['config']['THEME_DIR_INC'].'inc/promo.inc.php'); ?> 
    </div>
  <div id="main">
    <?php require($this->view_location); ?>

  </div>
  <?php include($data['config']['THEME_DIR_INC'].'inc/footer.inc.php'); ?>
</div>
</body>
</html>

Script

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"></script>
<script type="text/javascript">
    var jpop=$.noConflict(true);
jpop(document).ready(function() {   

        var id = '#dialog';

        //Get the screen height and width
        var maskHeight = jpop(document).height();
        var maskWidth = jpop(window).width();

        //Set heigth and width to mask to fill up the whole screen
        jpop('#mask').css({'width':maskWidth,'height':maskHeight});

        //transition effect     
        jpop('#mask').fadeIn(1000); 
        jpop('#mask').fadeTo("slow",0.8);   

        //Get the window height and width
        var winH = $(window).height();
        var winW = $(window).width();

        //Set the popup window to center
        jpop(id).css('top',  winH/2-$(id).height()/2);
        jpop(id).css('left', winW/2-$(id).width()/2);

        //transition effect
        jpop(id).fadeIn(2000);  

    //if close button is clicked
    jpop('.window .close').click(function (e) {
        //Cancel the link behavior
        e.preventDefault();

        jpop('#mask').hide();
        jpop('.window').hide();
    });     

    //if mask is clicked
    jpop('#mask').click(function () {
        jpop(this).hide();
        jpop('.window').hide();
    });     

});

</script>

you have to add css to your boxes div

div#boxes{
    position:fixed;
    z-index: 99; /* so that the div stays on top of others */
    top: 50px; /* distance from the top */
    height: 400px; /*set as neccessary */
    width: 400px;  /*set as neccessary */

    /* To center the box */
    margin-left: auto;
    margin-right: auto;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM