Forums

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

Home Forums CSS Combining fixed position and margin %

  • This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #43079
    copaesthetic
    Member

    I’m trying to set a [fixed navigation menu](http://i.imgur.com/iqcNj75.png “fixed navigation menu”) on a liquid layout, whereby the list items have a margin-left: 25% The problem I’m encountering is the links (list items) become un-clickable.

    However if I do any of the following, the links begin to work again:

    1. remove “position: fixed” from “nav ul” (can’t, needs to be fixed)

    2. specify “px” instead of “%” for margin-left under “nav ul li a” (can’t, needs to be liquid in width)

    3. remove “position: relative” from next container div in the HTML (can’t, it uses z-index)

    nav {
    }
    nav ul {
    width: 100%;
    position: fixed;
    }
    nav ul li {
    height: 18px;
    margin: 4px 0;
    }
    nav ul li a {
    font-size: 1.8em;
    font-weight: bold;
    margin-left: 25%;
    }

    #126615
    Paulie_D
    Member

    We need to see a live link or a Codepen with HTML & CSS

    #126730
    Merri
    Participant

    Give a bigger z-index to nav ul.

    #126747
    Paulie_D
    Member

    Probably something to do with this…

    >3. remove “position: relative” from next container div in the HTML (can’t, it uses z-index)

    A live link would be ideal….

    #127762
    copaesthetic
    Member

    Alright, here is a live link http://tinyurl.com/clsgbrk

    Thanks

    #127767
    wolfcry911
    Participant

    The container (960px wide) is covering the nav. Your content is only 520px wide, so why not make the container the same? Then lose the large left padding on the children.

    That will get you close, but at smaller screen sizes the nav links are still covered. I’d work towards centering the nav and shifting the links to the left.

    #127808
    copaesthetic
    Member

    Thanks @wolfcry911

    I didn’t even realize that, I was so focused on the content it didn’t occur to me the width of the container can still essentially cover the nav and render it unusable. Yeah, I plan on making it responsive and center the nav at smaller sizes :)

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