Reputation: 2697
I'm working with a piece of HTML similar to this:
<div id='headerBar'>
<div id='headerBarContent'>
<div id='leftContentSubdiv'></div>
<div id='rightContentSubdiv'></div>
</div>
</div>
With CSS like this:
#headerBar
{
position: fixed;
left: 0px;
right: 0px;
min-width: 1024px;
width: 100%;
height: 34px;
z-index: 10000;
}
#headerBarContent
{
display: inline-block;
position: absolute;
left: 50%;
margin-left: -512px;
width: 1024px;
}
#leftContentSubdiv, #rightContentSubdiv
{
position: relative;
width: 512px;
height: 34px;
}
What i'm trying to create is a header bar that scrolls vertically along with the page, and that scrolls horizontally when the window is smaller than the headerBarContent's width, without the use of JavaScript.
Facebook implements it exactly as I specified, without the use of JavaScript.
Twitter implements it with JavaScript
The Onion illustrates where I'm stuck at now. The page is unable to scroll the header bar horizontally with the rest of the page once the window size is smaller than the header's centered content
I can't figure out what exactly Facebook is doing in the markup have this functionality. Can anyone help?
Upvotes: 2
Views: 952
Reputation: 14746
If I correctly understand your problem, if the screen is < 1024px (headerBarContent) you want the header position to be relative.. right? (like Facebook)..
You could achieve this without JS by media queries i.e. :
@media screen and (max-width: 1024px){
#headerBar{
position:relative;
}
}
demo http://jsfiddle.net/BPcfB/
Upvotes: 1