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

  • Home
  • SEARCH
  • 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 6123853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:03:56+00:00 2026-05-23T16:03:56+00:00

We have a script used to edit certain files inline. Basically, each file is

  • 0

We have a script used to edit certain files inline. Basically, each file is broken down into sections, and hovering over a section will bring up a set of tools (just a div with image buttons) that you can use to edit that particular section. We have the parent elements (sections) set as position: relative, and the set of tools set as position:absolute which are set to the right side of the section. This all works fine, especially since many of these are rather small.

However, we do have many of these sections which can become quite large, reaching lengths of two screens or even more. In these cases we would like for the tools to sort of flow with the user’s scrolling, so say if the user is looking at the vertical-middle of the section, the buttons will rest at the vertical middle as well, however, if the vertical center of the user’s screen scrolls past the section but the user is still hovering over the section, we would like for the tools to remain within their parent element and not be able to pop out.

We already have a script to move an element with the user’s scroll if it goes out of the screen, so I was thinking I could modify that a bit to do that, I’m just not sure how to bound the element by it’s parent.

TL;DR: How would I create an element that attempts to be vertically centered in the user’s window, but cannot leave it’s parent element.

  • 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-05-23T16:03:57+00:00Added an answer on May 23, 2026 at 4:03 pm

    Here’s a quick implementation I came up with based on Andreas’s suggestion

    $(window).scroll(function(){
        var a = $(window).scrollTop() + ($(window).height() * .35);
        var b = $("#movedelement");
        var c = $(window).scrollTop() + ($(window).height() * .48);
    
        if (a < (b.parent().offset().top + 8))
            b.css({position: "absolute", top: "1em" });
        else if (c > (b.parent().offset().top + b.parent().height() - 8))
            b.css({position: "absolute", top: b.parent().height() - 100 });
        else
            b.css({position: "fixed", top: "35%" });
    }
    

    Tweak some numbers around for the element height. Dirty, but works.

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

Sidebar

Related Questions

I have a simple script which is used to start another program. This other
I have a TSQL script that is used to set up a database as
Does anyone have a Powershell script to change the credentials used by a Windows
I have a script that takes a table name and generates a control file
I have a CKEditor used to edit a text in a web-page. In the
I have a Bash script that repeatedly copies files every 5 seconds. But this
I created a small script I use for 'cleaning' sitemap file from certain links.
I have a php script that is reading a remote CSV file, and adding
I have used this header in my site: <head> <script type=text/javascript src=libs/jquery.js></script> <script type=text/javascript
I have used several different scripts that people have suggested for trying to parse

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.