Forums

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

Home Forums CSS [Solved] Using position: fixed; inside a wrapper?

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #30249
    Voltron
    Member

    Not sure if this is possible, so running it by you guys to see if you’ve seen any working examples.

    I use a bit of jscript on my site that detects the browser width, and assigns a different class based on a threshold (ie a ‘narrow’ version of the site and a ‘wide’ version). On the narrow version, I use a width of 100% and therefore putting my menu on a fixed position binds it to the side of the browser. On the wide version, I have a wrapper of a set pixel size using the margin: 0 auto; method, but I can’t get the menu to bind to the side of the wrapper.

    At the moment I have it so widescreen monitors get an absolute positioned menu, while the narrow versions get the fixed. If you want to see what I mean go to http://unstoppablevoltron.com and un-maximise your browser, resize so it’s say 900px wide and hit refresh and the different mode should kick in.

    Its not the end of the world if I can’t fix this, but I prefer the fixed menu system personally and know a lot of users won’t see it right now.

    Cheers

    #79500
    noahgelman
    Participant

    This might make it easier. Don’t use javascript for this sort of thing. You can use CSS to do it (although it doesn’t work on IE, nothing ever does.) They’re called “Resolution Specific Stylesheets”.

    BUT. If you’re adamant about using Java for it, go ahead, you’ll basically get the same result. Here is a link on how to do both, a bit more dynamically then you’re doing it.

    https://css-tricks.com/resolution-specific-stylesheets/

    #79509
    Voltron
    Member

    Cheers man, I’ll take a look through that and see if it helps out at all. I’m not convinced that the issue is due to it being a JS call though, more the fact that I’m having difficulties with telling the fixed element where it should be fixed to, but maybe switching to CSS might give me an alternative approach.

    #79565
    Voltron
    Member

    Eric, you’re a star. Hadn’t considered using the margin-left, and it’s worked perfectly in a single command! Much appreciated.

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