65.9K
CodeProject is changing. Read more.
Home

Fixed or Sticky header or ASP.NET webpage

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.89/5 (6 votes)

Dec 16, 2010

CPOL
viewsIcon

51942

Fixed or Sticky header or ASP.NET webpage

If you want the header section of the website to be fixed on top with menus and other information, you can simply use the below CSS to do so:
        .header
        {
            background-color:Gray;
            width:100%;
            height:100px;
            position:fixed;
            top:0px;
            margin:0px;
            padding:0px;
        }

        body
        {
            padding-top:110px;
            margin:0px;
        }
Use it like:
        <div class="header">
               Header content goes here...
        </div>
        <div>
               Body content goes here...
        </div>
This can be used with Master pages too.