Friday, July 25th — CSS Fixed Sidebar

July 25, 2008

Today I Learned…

…how to make a sidebar/navbar for a website fixed and stay put as the rest of the website scrolls. I’m learning CSS for my job with a psych lab at UVa, and our post doc wanted the navigation bar on the right side of the page to always be visible, even at the bottom of the content.

It requires a very simple command, which is frustrating, because I couldn’t find it for a week. You need to set the position property of the #navbar element or whatever it’s called in your stylesheet to fixed !important. That will make sure that the element doesn’t move, and that the declaration will override any normal declarations that you make elsewhere.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: