Display Details like lightBox
Dear Sir/Madam
pls refer
Green button
we get popup and small div inside
This part is working the way I want
however when we scroll down the dark background and the pop div also get scrolled.
I want their position fixed
html
- <!--- DIV with dark back ground -->
- <div class="popbg" id="mainbgdiv" >
- </div>
- <!--- DIV with Data -->
- <div class="popdata" id="insidediv">
- </div>
css
- /*--------------------Center DIV--------------*/
- html,body{height:100%;}
- div.popbg{ /* backgroung-container*/
- width:100%;
- height:100%;
- position:absolute;
- background: rgba(0,0,0,.6);
-
- z-index: 999;
- display: none;
- }
- div.popdata{
- width:50%;
- height:50%;
- color:white;
- background:#e0e0e0;
- border-radius: 10px;
- text-align:center;
- z-index:9999;
- display:none;
- position:absolute;
- }
Jquery [ center DIV]
- //--------close pop ------------------------//
- $('#popclose').click(function() {
- $('#insidediv').empty();
- $(".popbg").hide();
- $('.popdata').hide();
- });
- //--------------Center Div---------------//
- jQuery.fn.center = function(parent) {
- if (parent) {
- parent = this.parent();
- } else {
- parent = window;
- }
- this.css({
- "position": "absolute",
- "top": ((($(parent).height() - this.outerHeight()) / 2) + $(parent).scrollTop() + "px"),
- "left": ((($(parent).width() - this.outerWidth()) / 2) + $(parent).scrollLeft() + "px")
- });
- return this;
- }