views:

632

answers:

2

I have a top navigation area with position: fixed

I'd like the page content to scroll normally, but not disappear under the navigation. The main issue is when I do a search, (this is a full CMS with hundreds of results in different modules) what I'm searching for sometimes gets scrolled under the navigation. I'm ok with it because I know what's happening, but I'd like it to work well for my users. I suppose I could use a frameset, but is there another way?

A: 

May not be foolproof, but you could do

body {
  position: relative;
  top: <whatever height your navigation bar is>;
}

Then your navigation element would have

#nav {
  position: fixed;
}

Combined, this should bump everything under body down, except for those elements that have position: fixed or position: absolute.

Seph
This seems to only push the content down without preventing scroll-under. Still a neat idea. I've never thought about positioning the body element.
Stephane
What do you mean by "scroll-under"?
Seph
A: 

I'm the OP, but I can't figure out how to tie these two accounts together...

@Seph:

I basically have what you typed up except I have a content div with margin-top: 50px. The problem is, the content div scrolls with the page so I have 50px of hidden content once the page starts to scroll. This is especially apparent if I do browser searches (Ctrl-F). I've solved the printing issue with a @print stylesheet removing the nav area, but I'd like to have the scrolling occur only below the nav.

I was thinking of trying:

body {
overflow: no-scroll; (or whatever the css is for this)
}

#content {
overflow: scroll;
}

This might get rid of the browser scroll-bar and only have one for the content area. Not sure how that will look. Still less than ideal. It'll probably look just like a frameset without the frameset annoyances.

Stephane
If anyone wants to try this, here's what I discovered:-anchors within a page no longer scroll the page-in-browser searching messes up the layout a bit (I used jquery to get the window size, then subtracted the navigation height... the search bar takes up window space so it moves things around a bit)-the left and bottom scrollbars tend to go off-screen in 100% width or height layout.. if you just use display:block, the vertical scroll seems to work fine except that searching still does some strange things (tested Safari and Firefox).
Stephane