Skip to main content

How to Freeze Pane/Fix Website Header and Horizontal Nav Bar



I currently have a banner/header as well as a horizontal navigation menu below this header that I would like to freeze pane/fix, so that any content below this header/nav just scrolls beneath it, always.





FYI, need it to work in IE8.





I have setup the following skeleton structure of this as follows:







<div id="banner-nav">

<div id="banner">

<div id="nav">

</div>

</div>

</div>



<div id="content">

</div>







Would appreciate your help on this. If it cannot be done on the above fashion, any other alternatives that would accomplish my requirement, would be great.





Thanks.


Comments

  1. change

    <div id="banner-nav">


    to

    <div id="banner-nav" style="position:fixed">

    ReplyDelete
  2. You need to apply fixed positioning to your banner-nav element:

    #banner-nav {
    position:fixed;
    width:100%;
    }


    To get this to work in IE7+, you need a doctype that makes the browser render in "standards mode". The HTML5 doctype should do this:

    <!DOCTYPE html>

    ReplyDelete

Post a Comment

Popular posts from this blog

Why is this Javascript much *slower* than its jQuery equivalent?

I have a HTML list of about 500 items and a "filter" box above it. I started by using jQuery to filter the list when I typed a letter (timing code added later): $('#filter').keyup( function() { var jqStart = (new Date).getTime(); var search = $(this).val().toLowerCase(); var $list = $('ul.ablist > li'); $list.each( function() { if ( $(this).text().toLowerCase().indexOf(search) === -1 ) $(this).hide(); else $(this).show(); } ); console.log('Time: ' + ((new Date).getTime() - jqStart)); } ); However, there was a couple of seconds delay after typing each letter (particularly the first letter). So I thought it may be slightly quicker if I used plain Javascript (I read recently that jQuery's each function is particularly slow). Here's my JS equivalent: document.getElementById('filter').addEventListener( 'keyup', function () { var jsStart = (new Date).getTime()...

Is it possible to have IF statement in an Echo statement in PHP

Thanks in advance. I did look at the other questions/answers that were similar and didn't find exactly what I was looking for. I'm trying to do this, am I on the right path? echo " <div id='tabs-".$match."'> <textarea id='".$match."' name='".$match."'>". if ($COLUMN_NAME === $match) { echo $FIELD_WITH_COLUMN_NAME; } else { } ."</textarea> <script type='text/javascript'> CKEDITOR.replace( '".$match."' ); </script> </div>"; I am getting the following error message in the browser: Parse error: syntax error, unexpected T_IF Please let me know if this is the right way to go about nesting an IF statement inside an echo. Thank you.