tags:

views:

125

answers:

2

I want to create a very simple tab style that looks like this:

  _____   _____   _____
_|_____|_|     |_|_____|______________

So basically there is a horizontal border on the bounding box that breaks for the active tab. I'm using a basic list, with the following CSS, but the outer border always appears over the individual tabs. I've tried various positioning and z-index as well to no avail.

ul.tabHolder {
    overflow: hidden;
    clear: both;
    margin: 1em 0;
    padding: 0;
    border-bottom: 1px solid #666;
}
ul.tabHolder li {
    list-style: none;
    float: left;
    margin: 0 3px -1px; /* -1 margin to move tab down 1px */
    padding: 3px 8px;
    background-color: #444;
    border: 1px solid #666;
    font-size: 15px;
}
ul.tabHolder li.active {
    background-color: #944;
    border-bottom: 1px solid #944;
}
+1  A: 

http://css.maxdesign.com.au/listamatic/horizontal05.htm

ghoppe
In the end I didn't have to change my code a whole lot, but this page helped me work it out.
DisgruntledGoat
A: 

Changing your existing code as little as possible - try display: inline-block for the li tags, with the border on a .menu container div:

.menu {
    border-bottom: 1px solid #666;
}
ul.tabHolder {
    overflow: hidden;
    margin: 1em 0 -2px;
    padding: 0;
}
ul.tabHolder li {
    list-style: none;
    display: inline-block;
    margin: 0 3px;
    padding: 3px 8px 0;
    background-color: #444;
    border: 1px solid #666;
    font-size: 15px;
}
ul.tabHolder li.active {
    background-color: #944;
    border-bottom-color: #944;
}

HTML used to illustrate (added div at bottom to show blending of active tab into div colour):

<div class="menu">
    <ul class="tabHolder">
        <li>Menu 1</li>
        <li class="active">Menu 2</li>
        <li>Menu 3</li>
    </ul>
</div>
<div style="background-color: #944; height: 1em">
Dave Everitt
...or Eric Meyer's solution, as posted by ghoppe while I was writing this :-)
Dave Everitt
Looks better if you set the `margin-bottom` on `ul.tabHolder` to `-1px` instead of `-2px` - http://jsfiddle.net/mrPAE/
Sam
Depends on the browser - in FF 3.6.3 (OS X) 1px doesn't hide the bottom border. Meyer's solution seems cleanest.
Dave Everitt
It occurred to me as I was reading this that there is a tab menu right above these answers… the css looks similar to Meyer's tabs. Maybe inspect the css of this very page to get ideas. :)
ghoppe