ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Unordered List Horizontal Menu Help

December 10, 2007 12:06pm

Subscribe [2]
  • #1 / Dec 10, 2007 12:06pm

    Michael Wales

    2070 posts

    I hate Internet Explorer… IE6 and IE7 are both ignored anchor element padding whereas Firefox does exactly as I’d like. Any help is appreciated.

    Note: the xHTML is incomplete - I am knocked these out one tab at a time. The CSS may look goofy because I was tossing in a lot of different ideas trying to get IE to comply - things like the positioning of the anchor element (which all lead to no change in the results).

    xHTML:

    <div id="nav">
      <ul>
        <li class="menu_home_active"><?= anchor('', '<span>Home</span>'); ?></li>
        <li class="menu_services"><?= anchor('services', '<span>Services</span>'); ?></li>
        <li><?= anchor('portfolio', '<span>Portfolio</span>'); ?></li>
        <li><?= anchor('blog', '<span>Blog</span>'); ?></li>
        <li><?= anchor('about', '<span>About</span>'); ?></li>
        <li><?= anchor('contact', '<span>Contact</span>'); ?></li>
      </ul>
    </div>


    CSS:

    #nav {height:32px;}
    #nav ul, #nav li {list-style:none;padding:0;margin:0;}
    #nav ul li {float:left;margin-right:10px;height:32px;line-height:32px;}
    #nav ul li span {display:none;}
    li.menu_home_active {
        background:transparent url(../img/menu_home_active.png) no-repeat top left;
        width:69px;
    }
    li.menu_home_active a {
        position:relative;
        padding-right:67px;
        padding-bottom:15px;
    }
    
    li.menu_services {
        background:transparent url(../img/menu_services.png) no-repeat top left;
        width:91px;
    }
    li.menu_services a {
        border:1px solid #000;
        padding-right:89px;
        padding-bottom:15px;
    }


    Check the attached images for how the site appears in FF (for some reason Photoshop won’t paste from a Print Screen on this computer, so I can’t get an IE screenshot. Needless to say, the Services tab does not have the black border).

  • #2 / Dec 10, 2007 1:34pm

    xwero

    4145 posts

    try

    li.menu_services a {
        border:1px solid #000;
        padding-right:89px;
        padding-bottom:15px;
        zoom:1; /* ie hack */
    }

    That would be my first guess : the peekaboo bug.

    The best way to deal with this kind of hacks is conditional css comments

  • #3 / Dec 10, 2007 2:45pm

    Michael Wales

    2070 posts

    Thank you very much xwero - at least I have a link appearing now.

    I fully intended to rock a conditional stylesheet for IE (which I will still need to do, thanks to padding differences) but at least I can see the link now. :D

  • #4 / Dec 10, 2007 3:14pm

    Nick Husher

    364 posts

    I’m not exactly sure what you’re trying to do. The attached image seems to indicate that you want a tabbed menu, which isn’t too terrably hard. That said, try setting display: block on the anchor elements. Anchors are by-default rendered as inline boxes, which means that any changes to width or padding should be ignored.

    ul.menu {
        list-style-type: none;
        margin: 0; padding: 0;
        height: 32px; width: 100%;
    }
    ul.menu li {
        /* Note: display is set to inline to work 
        around the IE6 double margin bug:
        <a href="http://www.positioniseverything.net/explorer/doubled-margin.html">http://www.positioniseverything.net/explorer/doubled-margin.html</a>
    
        Good browsers will ignore the display rule
        because floated objects are, by definition,
        block-level elements.
        */
        float: left; display: inline;
        margin: 0 8px 0 0; padding: 0;
        width: 90px; height: 32px;
        background: #ccc;
    }
    ul.menu li a {
        display: block;
        width: 100%; height: 32px;
        background: #c00;
    }
    ul.menu li a span { position: absolute; top: -9999px; }

    That will display five red tabs with no labels indentically in Firefox, Opera, and IE6, and probably all the rest. Just replace the red (#c00) and gray (#ccc) backgrounds with the ones you want and you have the effect you want.

    DEMO: http://demos.nickol.us/nickolus/tabtest.html

  • #5 / Dec 10, 2007 3:53pm

    Michael Wales

    2070 posts

    Even better nhusher - position:relative and display:block are working perfectly, with no need for conditional statements.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases