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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:44:26+00:00 2026-05-23T11:44:26+00:00

I have a div that displays near a control when it’s focused on. Initially,

  • 0

I have a div that displays near a control when it’s focused on. Initially, the div was on the left of the control, and life was easy. A simple if left < 0 { left = 0; } would keep the div on the screen. Now the div needs to be on the right, and I can’t figure out a similar bit of code. Also, the code needs to determine not only if it’s off-screen to the right, but also if it’s past the visibility of a (possible) scrollable containing div. How can I accomplish this? Assume the scrollable div, if applicable, can be found with $('.PanelScroll') and we can call the div needing placement elem.

  • 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-23T11:44:27+00:00Added an answer on May 23, 2026 at 11:44 am

    This is more of the simple solution I was looking for:

    var ctrl = $('#<your control id>');         // This is the control that the div is display to the right of.
    var elem = $('#<your element id>');         // This is the div that may be out of view.
    var panel = $('#<your scrollable div id>');
    var left = elem.position().left;
    var right = left + elem.outerWidth();
    
    if ((panel.length && (right > panel.innerWidth())) || (right > ($(window).width() + $(window).scrollLeft()))) {
        left = left - ctrl.outerWidth() - elem.outerWidth();
    }
    
    if (panel.length) {
        left += panel.scrollLeft();
    }
    
    elem.css('left', left);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a javascript that displays a generated text into a div: document.getElementById('phrase').innerHTML =
I have a web page that displays a long line graph inside a div
I have a jquery toggle that animates and displays a DIV. I have a
I have this page that displays pictures in a div. I have jquery cycle
I have a div in the center of a page that displays some content.
I'm having difficulty setting up a simple menu that displays results on a div
have a box that displays images wrapped in a div from a database 4
I have some jquery code that displays and hides a div when a link
I have a div that displays a Google map. How do I make another
I have a <div> that displays a graph inside. Sometimes this graph gets too

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.