Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9281751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T18:11:54+00:00 2026-06-18T18:11:54+00:00

I have a Light Box Code that works great! You click on a button

  • 0

I have a Light Box Code that works great! You click on a button and then there is an overlay of a black screen and a content box. I am wanting to know if there is a way to make the light box or white_content in the CSS below appear on the screen based on how far down the user has scrolled down the page.

Basically, I am wanting to have the white_content appear in the middle of the view able screen.

http://s1309.beta.photobucket.com/user/mievan123/library/Light%20Box

  • The first image is showing the Light Box centered on the page and this is what I want. I am scrolled all the way down the the bottom of the page.

    Also you can see it in action at http://www.green-panda.com/solutions.html

  • The second image is showing the Light Box barely visible on the page. I scrolled up just a little as you can see. The Red Outline is where I want the Light Box to move to when i’m at that position.


Would a screen recording help make this question more clear?

All of my code is provided below:

My CSS for the light box

.black_overlay{
    display: none;
    position: fixed;
    top: 0%;
    left: 0%;
    width: 100%;
    height: 100%;
    background-color: black;
    z-index:1001;
    -moz-opacity: 0.8;
    opacity:.80;
    filter: alpha(opacity=80);
}
 
.white_content {
    display: none;
    position: absolute;
    top: 50%;
    left: 25%;
    width: 50%;
    height: 50%;
    padding: 16px;
    border: 16px solid green;
    background-color: white;
    z-index:1002;
    overflow: auto;
}

The script for opening the lightbox

<p align="right">
    <a href="javascript:void(0)" 
       class="button" 
       onclick="document.getElementById('light').style.display='block';
                document.getElementById('fade').style.display='block'"
    >Contact Us</a>
</p>

The actual lightbox coding

<div id="light" class="white_content">
    This is the lightbox content. 
    <a href="javascript:void(0)" 
       onclick = "document.getElementById('light').style.display='none';
                  document.getElementById('fade').style.display='none'"
    >Close</a>
</div>
<div id="fade" class="black_overlay"></div>

JSFiddle

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T18:11:55+00:00Added an answer on June 18, 2026 at 6:11 pm

    You can’t center it with the width and height being percentages (at least not without using JS).

    You can however set a static height and width and center it like this:

    Use top: 50%; left: 50%; and static, negative top and left margins, which should be half of the width/height of your element.

    .white_content {
        display: none;
        position: fixed;
        top: 50%;
        left: 50%;
        margin: -182px 0 0 -182px;
        width: 300px;
        height: 300px;
        padding: 16px;
        border: 16px solid green;
        background-color: white;
        z-index: 1002;
        overflow: auto;
    }
    

    JSFiddle

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got the following code that shows a lightbox 'please wait' box, then does
Hello there good people of stackoverflow. I have this code that basically get any
I'm using the JQuery prettyPhoto lightbox clone, and it works great, but I have
I have called the contact form in a cms page and then calling that
I have a simple example i am using FancyBox for the light box. I
I have some code that allows you to scroll back and forth between images
I have the following code in the header of a website that I'm working
I have some code that is a simple div with a css stylesheet that
Is there a way to have lightbox on page load?? Say like when the
I have a form on a lightbox, that form is server side validated with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.