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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:48:04+00:00 2026-06-01T13:48:04+00:00

i am adding a sticky scroll nav i think it is called, which allows

  • 0

i am adding a “sticky scroll” nav i think it is called, which allows the nav to move until it hits the top of the browser where it become fixed, i.e. always keeping it in the eye of the user.
I have managed to get it working in chrome, firefox and IE.

However one part of the jquery allows you to change the top margin at which it stops.

Is there anyway i can set the top margin differently for each browser, for example, chrome i want it to be 10px, and IE i want it to be 5px, firefox for some reason takes the whole of the screen with the Nav, so it does not need to be changed.

Here is the Jquery for it

<script type="text/javascript">
    $(function(){ // document ready

      if (!!$('.sticky').offset()) { // make sure ".sticky" element exists

        var stickyTop = $('.sticky').offset().top; // returns number 

        $(window).scroll(function(){ // scroll event

          var windowTop = $(window).scrollTop(); // returns number 

          if (stickyTop < windowTop){
            $('.sticky').css({ position: 'fixed', top: 0 });
          }
          else {
            $('.sticky').css('position','static');
          }

        });

      }

    });
</script>

You can see the top margin section top: 0

Any ideas?

Thanks

  • 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-01T13:48:05+00:00Added an answer on June 1, 2026 at 1:48 pm

    IF you want to go this route you can use $.browser (http://api.jquery.com/jQuery.browser/) to test which browser the user is using. This works in most cases, but it could break down if the user has changes the user-agent setting of his browser.

    What I suggest you do however is find out why this behavior exist and sold the underlying problem. It you cannot fix it or you have run out of time you can alway fall back to hacks like $.browser. 🙂

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

Sidebar

Related Questions

I have a 'sticky sidebar nav' that is positioned absolutely relative to the #sidebar
I'm trying to imitate how gMail sticks the header to the top on scroll,
Adding an element to the head of an alist (Associative list) is simple enough:
Adding source files more than one directory away (e.g. ../../source.cpp or ../../../somewhere_else/source.cpp, vs. just
Adding more than one child to a WPF StatusBar results in poor layout with
Adding Exceptional Handling is a good practise, but I have a doubt, In our
Adding the row one by one in the button click.. (i tried but its
Adding functionality to a class can be done by adding a method or by
Adding strings localization files in iPhone bundle is very simple and perfectly fine but
Adding member variables to a class certainly boosts the memory footprint of its instances

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.