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

The Archive Base Latest Questions

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

I would like to set a position fixed and relative. I have a large

  • 0

I would like to set a position fixed and relative. I have a large div for all my content. When i set the position of div inside to relative it aligns to the left of my content div. when i change that position to fixed it aligns to my browser side. I have been told that there is no css solution, but is there any other way.

basically im trying to get the same effect as the right hand bar on this website:
http://www.nytimes.com/interactive/us/sept-11-reckoning/viewer.html

Code:

 #content{
 width: 1000px;
 margin-right: auto;
  margin-left: auto;
 }

  #text{
  position: fixed;
  }


  <div id='content'>
        <div id='text'>Welcome to the site</div>
  </div>
  • 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-26T22:44:46+00:00Added an answer on May 26, 2026 at 10:44 pm

    The function isScrolledIntoView() used below is from another question Check if element is visible after scrolling

    Explanation of Example

    First off we have the function isScrolledIntoView() which simply returns true or false if an element is visible inside your browsers viewing area.

    You need to use two divs or some kind of anchor point and a follow div. Your anchor div is used to determine when we should switch the follow div to a fixed style to follow on scrolling or switch back to an absolute position if the anchor is back in view to return the follow div to its original position on the page.

    With your anchor point, following div, the function to check if an element is visible in the viewing area, we can make use of the jQuery .scroll() event binding method on the window to fire an event when the user scrolls on the page.

    Example Script

    $(window).scroll(function () {
        if (! isScrolledIntoView($('#anchor')))
        {
            // anchor div isn't visible in view so apply new style to follow div to follow on scroll
            $('#follow').css({ position: 'fixed', top: '10px' });
        }
        else
        {
            // anchor div is visible in view so apply default style back to follow div to place in default position
            $('#follow').css({ position: 'absolute', top: '100px' });
        }
    });
    
    function isScrolledIntoView(elem)
    {
        var docViewTop = $(window).scrollTop();
        var docViewBottom = docViewTop + $(window).height();
    
        var elemTop = $(elem).offset().top;
        var elemBottom = elemTop + $(elem).height();
    
        return ((elemBottom >= docViewTop) && (elemTop <= docViewBottom));
    }
    

    Fiddle demo

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

Sidebar

Related Questions

I wanted to set a top header in a fixed position and have content
I have an ImageButton and I would like to set its position programmatically to
i would like to set the date format of all the dates in my
I would like to make a position: fixed; popup box centered to the screen
I want to have a nav bar set position: fixed to the top of
I have three DIVs, something like this: <div id=header> ... </div> <div id=content> <div
I have a div.scroll_fixed with the following CSS .scroll_fixed { position:absolute top:210px } .scroll_fixed.fixed
I would like to mask a asp page by a div, this one have
I have a fixed-width web page (640 pixels wide). I would like this page
I would like to set the position of the scrolling bar in a determinated

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.