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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:16:41+00:00 2026-06-01T14:16:41+00:00

Better to give an example, to illustrate what i am describing. The div element

  • 0

Better to give an example, to illustrate what i am describing.

The div element with the list of categories starts mid page, but as the user scrolls down it remains at the top?

http://www.khanacademy.org/

I know how to make a fixed element. My question is how do i make the element appear by default in the center of the page, but as the user scrolls down, the element will stay at the top.

  • 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-01T14:16:43+00:00Added an answer on June 1, 2026 at 2:16 pm

    Here’s a quick jsFiddle example of what I think you’re looking for. Basically you have a div that is initially positioned relative, then as the page is scrolled, the position is changed to fixed. jQuery does the heavy liting here with the $(window).scroll event.

    jQuery:

    var stickerTop = parseInt($('#sticker').offset().top);
    $(window).scroll(function() {
        $("#sticker").css((parseInt($(window).scrollTop()) + parseInt($("#sticker").css('margin-top')) > stickerTop) ? {
            position: 'fixed',
            top: '0px'
        } : {
            position: 'relative'
        });
    });​
    

    CSS:

    body {
        width: 960px;
    }
    #mainbar {
        width: 660px;
        float: left;
    }
    #sidebar {
        width: 270px;
        float: right;
    }
    #sticker {
        width: 200px;
        padding: 10px;
        margin-top:25px;
        background: #eee;
        border: 1px solid #ccc;
    }​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ajax seems to give a better user experience, but I'm not so sure if
I've simplified my problem and created this example to better illustrate. My table: CREATE
I tried to put it in a sentence but it is better to give
I've updated the script here to give a better example. For $header I've got
Which code snippet will give better performance? The below code segments were written in
From here , I found that Colt's OpenIntIntHashMap and Trove's TIntIntHashMap give better performance
I am unsure on which approach will give me a better performance: I have
As mentioned above. I give one example, let's say all the test values are
I know for standard html attributes there are CSS selectors: span[class=example] But I would
Django documents give this example of associating extra data with a M2M relationship. Although

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.