Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Light box background color should cover the whole screen using CSS

This is my page URL

http://sample.com/mytest.php

In this page, if we click a Sign In button it will display a popup screen with black background. But if we zoom out the page, then it reduces the size of a background color. But i want to cover background the whole screen if we zoom out. I used the code below in my page.

.black_overlay{
  display: none;
  position: absolute;
  top: 0%;
  left: 0%;
  width: 100%;
  height: 2000%;
  background-color: black;
  z-index:1001;
  -moz-opacity: 0.8;
  opacity:.80;
  filter: alpha(opacity=80);
} 

But in a test page the below code is used for cover the whole background. It works fine.

<style type="text/css">
  /*give the body height:100% so that its child
    elements can have percentage heights*/
  body{ height:100% }
  /*this is what we want the div to look like*/
  div.fullscreen{
    display:block;
    /*set the div in the top-left corner of the screen*/
    position:absolute;
    top:0;
    left:0;
    background-color: black;
    /*set the width and height to 100% of the screen*/
    width:100%;
    height:100%;
    color: white;
  }
</style>

<div class="fullscreen">
  <p>Here is my div content!!</p>
</div>

How can i do the same for my login page background i don't know. Anyone can please help me to solve this problem.

like image 512
Rithu Avatar asked Dec 07 '12 10:12

Rithu


2 Answers

try

div.fullscreen{
    position:fixed
    ...
}

absolute: The element is positioned relative to its first positioned (not static) ancestor element
fixed: The element is positioned relative to the browser window

like image 185
Pieter Willaert Avatar answered Nov 02 '22 23:11

Pieter Willaert


You have to put below code before the end of the body tag or after starting of the body tag

<div class="black_overlay" id="fade" style="display: block;"></div>
like image 36
Sandip Makwana Avatar answered Nov 03 '22 00:11

Sandip Makwana