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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:30:16+00:00 2026-06-12T01:30:16+00:00

I need help with the following issue. I’m creating a responsive site. Its structure

  • 0

I need help with the following issue.

I’m creating a responsive site. Its structure is quite basic: header, nav bar, body and footer.

In the header I have several elements and all these elements use percentages for their dimensions, so the height of the header is determined by the height of the elements inside of it.

For the nav bar I plan to use a “sticky” script, so when you scroll the page, the nav bar ‘sticks’ to the top of the page, and once you go back all the way up, it ‘unsticks’ and appears under the header.

So far, so good.

Thing is that the sticky script depends on the height of the header in order to correctly stick the nav bar under the header. So when I resize my window to test the responsiveness of the layout, the sticky nav bar goes crazy.

What I need is a way to detect the height of the header and modify the DOM by creating a style on the <header> ie. (<header style="height:198.3px">), and assign a dynamic height to it as I resize the browser window.

I think this is something that would be accomplished using the height(); property, but I’m not a jQuery guru so I’m not sure if that would work.

Any help is greatly appreciated.

PS. BTW, Stackoverflow.com uses this ‘sticky’ feature on the boxes on the right column when you’re creating/editing a post.

  • 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-12T01:30:17+00:00Added an answer on June 12, 2026 at 1:30 am

    Something like this should get you started:

    var $sticky = $('#sticky');
    var $header = $('header');
    
    $(window).scroll(function() {
        if ($(this).scrollTop() > $header.offset().top + $header.height()) {
            $sticky.css({
                top: 0,
                position: 'fixed'
            });
        } else {
            $sticky.css({
                top: 'auto',
                position: 'absolute'
            });
        }
    }).trigger('scroll');​
    

    Demo: http://jsfiddle.net/Blender/S66gR/2/

    Instead of replicating CSS with JavaScript, just use what’s already there. position: fixed makes elements “stick” to the screen.

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

Sidebar

Related Questions

I need help with the following issue. I parse XML and do a XSLT
need value advice and help me to sort out the following issue. function max_key($array)
I need help doing the following: a preprocessor macro label(x) shall output #x, e.g.,
I'm fixing bugs for some application, and I need help understanding the following lines
I need some help extracting the following bits of information using regular expressions. Here
I need syntax help with the following code logic: I have a code block
I need help on the best way to design a database/tables for the following
I need help debugging some odd file behavior in Python. Take the following script
I need some help solving some compile errors. I was following a tutorial (at
I need some help writing a regex. I have the following strings, xxx.yyy.wwwwwaaa_IN_123 xxx.rrrttttt_IN_12355

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.