View Full Version : position overlay bang in center of page, with scroll disabled or like that.

11-23-2012, 10:10 AM
What I am trying to get is the overlay box to be positioned say 4 inches from the left side of the screen. With out the user having to scroll to the top of the page to view the overlay as it always goes to the top of the page by default.

How can this be positioned so it will go where the viewpoint of the window is at that time, or better still have it bang in the middle of the page with 'no' scroll effect for anything. overlay or the background which is the webpage.

relevant snippets of my code.


function showOverlay() {


<form action="addItem.php" method="post" enctype="multipart/form-data">
<input type="submit" name="upload" value="Upload Item" onclick="showOverlay();"> <input type="reset" value=" Clear ">

<div id="light" class="white_content"><div style="text-align: right;"><a href="javascript:void(0)" onclick="document.getElementById('light').style.display='none';document.getElementById('fade').style.display= 'none';"><img src="images/cross_close.png" class="fb_close" alt="close"></a></div>
<div id="fade" class="black_overlay">
// text to show.

if(isset($_SESSION['user'])) {
overLayBox("Your details are being updated, please wait.");


display: none;
position: absolute;
top: 0%;
left: 0%;
width: 100%;
height: 100%;
background-color: black;
-moz-opacity: 0.8;
filter: alpha(opacity=80);

.white_content {
display: none;
position: absolute;
top: 25%;
left: 25%;
width: 30%;
height: 55%;
padding: 1em;
border: 0.2em solid lightblue;
background-color: white;
overflow: auto;

11-23-2012, 04:53 PM
I can't see reinventing the wheel when every auto store is selling one. Look at these pages for a copy/paste answer to you problem:
http://lokeshdhakar.com/projects/lightbox/ for Lightbox JS

and: boxy here http://onehackoranother.com/projects/jquery/boxy/

11-23-2012, 09:29 PM
position : fixed is what you should use when you want to position relative to the browser rather than relative to the page. Then just set top and left values or bottom and right values to position it.