Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Fixed Header that isn’t overlapped by scrollbar?

  • This topic is empty.
Viewing 15 posts - 1 through 15 (of 20 total)
  • Author
    Posts
  • #43100
    patternicity
    Member

    I’m trying to figure out how to accomplish this, if it’s even possible at all:

    I have a fixed header across all pages of my site, and I don’t want it to be part of the “scrollable” content below. Basically, I want it to interact as if it were a separate iframe, without being a separate iframe…

    Is this possible with CSS?

    #126725
    Paulie_D
    Member

    No.

    Sorry…it’s just that simple.

    The scrollbar is not an HTML element…it’s a browser element.

    As far as I know, only Webkit will actually let you style it but you can’t change its fundamental functionality.

    #126726
    Merri
    Participant

    It is possible. But it is darn ugly.

    http://cdpn.io/xGujE

    #126735
    Paulie_D
    Member

    Wow, that is sneaky…but you’re right…it’s really ugly.

    Also it’s a maintainability nightmare as far as block formatting context goes.

    #126737
    Merri
    Participant

    It doesn’t work in Internet Explorer, even IE10 ignores the relative element’s boundaries or uses the wrong information to get it’s height. To make it work in IEs you’ll need a real table element in the markup as I do remember getting this to work cross-browser a few years ago. The result of having interest on doing “the impossible” :)

    You can use almost the same kind of table trick to make a site always have a min-height of 100% to fill the whole viewport, and it can be expanded on centering content to the middle of the screen, yet if content is too tall you’ll get a scroll bar – unlike with absolute or fixed positioning where you’d lose the top of the content.

    The conclusion for all of these table tricks: not recommended on any real site.

    #126755
    Paulie_D
    Member

    I do wonder why this is even required…the viewer is, at best, not going to notice or care or, at worst will be confused.

    #126762
    patternicity
    Member

    @Paulie_D, think of apps with fixed navigation. The scrollbar doesn’t overlap that, and why should it? It’s not being scrolled. The same should apply to web design, I think.

    #126764
    Merri
    Participant

    @CrocoDillon: ah yes, box-sizing is indeed a game changer these days. Can again do tricks that only worked in quirks mode previously :) Your example will need to add both -moz-box-sizing and -webkit-box-sizing to give it a better browser support, other than that I was surprised to see that even IE8 supports box-sizing: border-box; ( http://caniuse.com/#search=box-sizing ) which makes it an actually usable feature on most sites.


    @patternicity
    : This is bit of a troublesome case for mobile devices. When implementing you probably want to also do a responsive design so you’ll only serve this kind of interface to high resolution devices that can afford the space.

    #126773
    Paulie_D
    Member

    >think of apps with fixed navigation.

    If I’m using a mobile app, I’m not using the scrollbar…I’m using my fingers.

    On a desktop all you will do is confuse users.

    #126776
    patternicity
    Member

    It doesn’t matter _how_ you’re scrolling, it matters _what_ you’re scrolling. Whether it’s with your finger or with a mouse or trackpad, part of the content is moving and part of it is fixed.

    Open up any application on your computer. Let’s take iTunes, for example. You probably have two scrollbars—one for the sidebar and one for the main content. Do either of these scrollbars extend into the control bar at the top? Of course not. They have no reason to. The control bar isn’t scrollable. The web, I am arguing, should function the same.

    #126779
    Paulie_D
    Member

    You can argue if you wish but the webpage has got along fine just as it is for many years now without feeling the need to start a new way of scrolling.

    Frankly the only reason I can think of for a scrollbar on mobile is for a visual representation of how far down the page I am.

    If you’re happy with it that’s fine though and in any case, I scroll with my mouse and not the scrollbar so perhaps the point is moot.

    #126780
    patternicity
    Member

    This isn’t a new way of scrolling at all. It’s an attempt to correct improper visual cues that shouldn’t exist today.

    And I dunno what OS you use, but on OS X and iOS the scrollbars are identical—invisible until hover or touch.

    #126781
    patternicity
    Member

    (http://codepen.io/anon/full/Bcfkr “Fixed Header solution”)

    As an example of this method in-practice, take a look at [Grooveshark](http://grooveshark.com/ “Grooveshark”).

    #126867
    Merri
    Participant

    It might be historical reasons, actually. IE6 didn’t allow to combine top and bottom or left and right so it doesn’t easily come back to mind once you have the mindset of *it can’t be done* for so long :)

    So here is initial simplifying:
    http://codepen.io/Merri/pen/ebKtf

    But if one wants to be really clever and aim for the minimal amount of HTML:
    http://codepen.io/Merri/pen/kEpwI

    However I haven’t tested browser compatibility to see how many browsers actually allow to set position: absolute; on body element.

    **Update!**

    1. All non-IE desktop browsers seem to be OK!
    2. Internet Explorer 8+ is OK!
    3. Internet Explorer 7 is almost OK! (displays extra disabled vertical scrollbar)
    4. IE6 doesn’t even support position: fixed; so no luck to be expected. Didn’t allow the position: absolute; on body either.

    #240226
    BetoSoft
    Participant

    Thanks for pointing the solution @Merri. I’ve been looking for this and it works almost perfect…
    The only thing is that in mobile browsers you can’t reload a page using scroll up, at least in Chrome… it could be an important feature for some websites :/
    I think that ‘html { overflow:hidden; }’ is the culprit.

Viewing 15 posts - 1 through 15 (of 20 total)
  • The forum ‘CSS’ is closed to new topics and replies.