Search code examples
jquerycssjquery-tabs

Tab Wrapping Behavior with CSS and jquery.tools tabs


I am getting some strange wrapping behavior in Chrome with jquery tools tabs: enter image description here

When the browser is larger, they all just appear in one row. The CSS for the tabs is:

/* root element for tabs  */
ul.tabs {  
    margin:0 !important; 
    padding:0;
    height:30px;
    border-bottom:1px solid #666;       
}

/* single tab */
ul.tabs li {  
    float:left;  
    padding:0; 
    margin:0;  
    list-style-type:none;   
}

/* link inside the tab. uses a background image */
ul.tabs a { 
    float:left;
    font-size:13px;
    display:block;
    padding:5px 30px;   
    text-decoration:none;
    border:1px solid #666;  
    border-bottom:0px;
    height:18px;
    background-color:#efefef;
    color:#777;
    margin-right:2px;
    position:relative;
    top:1px;    
    outline:0;
    -moz-border-radius:4px 4px 0 0; 
}

ul.tabs a:hover {
    background-color:#F7F7F7;
    color:#333;
}

/* selected tab */
ul.tabs a.current {
    background-color:#ddd;
    border-bottom:1px solid #ddd;   
    color:#000; 
    cursor:default;
}


/* tab pane */
.panes div {
    display:none;
    border:1px solid #666;
    border-width:0 1px 1px 1px;
    min-height:150px;
    padding:15px 20px;
    background-color:#ddd;  
}

The Over all structure of this page is: enter image description here

Anyone have any suggestions on how I mix fix or work around this?


Solution

    • I added overflow: hidden to ul.tabs to clear the floated elements (tabs).
    • I added border-bottom: 1px solid transparent to offset the problem, which was having on ul.tabs a.current this: border-bottom:1px solid #ddd.
    • The border was making that one tab 1px higher than the other tabs, but the 1px of transparent border ensures consistent height.
    • When you have floated elements that are different heights, you get these sorts of problems.

    See: http://jsfiddle.net/me9XZ/3/

    I tested in Chrome/Firefox.