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 8217639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:31:39+00:00 2026-06-07T12:31:39+00:00

I have an image pop-up ability on my website, in order to show users

  • 0

I have an image pop-up ability on my website, in order to show users the full resolution picture when they click on a smaller version on the page.

This is the current CSS that positions it:

div#enlargedImgWrapper {
    position: absolute;
    top: 30px;
    left: 55px;
    z-index: 999;
}

The problem now is that if I click on an image further down the page, the window still appears in the top left corner of the page, where I can’t see it until I scroll back up. I need it to appear relative to the window, whatever its current position relative to the document is.

Note: I don’t want to use position: fixed; as some images might be taller than the screen, so I want users to be able to scroll along the image as well.

My idea was to use JS to change the top value:

var scrollValue = ???;
document.getElementById('enlargedImgWrapper').style.top = scrollValue+30 + 'px';

How can I detect by how much the user has scrolled down the page (var scrollValue)?
Or is there a ‘better’ way to do this?

Edit: if possible I would like to do this without jQuery.

  • 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-07T12:31:44+00:00Added an answer on June 7, 2026 at 12:31 pm

    Pure JavaScript uses scrollTop and scrollLeft:

    var scrollLeft = (window.pageXOffset !== undefined) ? window.pageXOffset : (document.documentElement || document.body.parentNode || document.body).scrollLeft;
    var scrollTop = (window.pageYOffset !== undefined) ? window.pageYOffset : (document.documentElement || document.body.parentNode || document.body).scrollTop;
    

    https://developer.mozilla.org/en-US/docs/Web/API/Element.scrollTop

    jQuery version:

    var scrollLeft = $(window).scrollLeft() ;
    var scrollTop = $(window).scrollTop() ;
    

    What you need is this:

    document.getElementById('enlargedImgWrapper').style.top = (scrollTop+30) + 'px';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a thumbnail image you can click to open a full size image
I'd like to have an image in my iphone app pop-in on screen rather
I have a code for my site, when an image is clicked a pop
I have image A and image B. They are located in the different places
I'm trying to figure out how i can have an image with click-able content.
I have an image button on a pop up page which is opened by
I wanna do something like a Pop Picture Game, when you have an album
On click of image, I want it to pop-out with the transparent bacground. I
I have a fairly simple page that displays an image in a pop-up window.
I have this code: $jq('.pop-tip').click( function(event) { width = ''; height = ''; var

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.