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

The Archive Base Latest Questions

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

I want a div element to do something similar to gmail. When scrolling down,

  • 0

I want a div element to do something similar to gmail.

  • When scrolling down, once gmail’s menu (Archive, Spam, Delete…etc) reaches the the top of the screen, it stays there.

  • When scrolling up, the menu returns to it’s original position.

Another sample is the side bar of this page: sample 2

How to achieve that with a simple (and easy to understand) jQuery code?
(Compatible with all browsers)

<div id="header">Menu goes here =)</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-26T03:44:58+00:00Added an answer on May 26, 2026 at 3:44 am

    Specific to your problem, try this:

    CSS:

    #header.floating {
        position: fixed;
        top: 0;
    }
    

    JavaScript:

    $(document).ready( function() {
    
        $(window).scroll( function() {
            if ($(window).scrollTop() > $('#header-wrapper').offset().top)
                $('#header').addClass('floating');
            else
                $('#header').removeClass('floating');
        } );
    
    } );
    

    jsFiddle: http://jsfiddle.net/omarjuvera/0p9p43Lz/

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

Sidebar

Related Questions

I want to select recently created element doing something like this: $(body).append(<div id='popup.dialog'></div>); dialogDiv
I am wanting something similar to this person , except the element I want
I want a div element, in a bottom of window. like a div in
I have a script that create a new div element. Then, I want to
I want to take an ExtJS element(div) retrieved from the DOM selector, and convert
I want to get the id of the clicked element and then show div
I want to right-align an inline element to the right of a div .
I have an element, like this: <div id=navleft> </div> I want to make this
Basically I want to implement something similar to the the cell-coloring which is defined
I want to set focus on the first form element in a div, either

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.