masterfan masterfan - 3 months ago 20
CSS Question

Expand horizontally not vertically

As you can see on the gif below, my 'Tabs' are expanding vertically. However I want them to expand horizontally. I already tried with 'white-space:nowrap', and other things that proved to work for other people, but it just doesn't work in my case.

Image Example

HTML:

<div class="l_tabs">
<div>
<ul id="myTab1" class="nav nav-tabs bordered">
<li class="tab-add">
<li class="contentTab">
<li class="contentTab">
<li class="contentTab">
<li class="contentTab">
<li class="contentTab">
<li class="contentTab active">
</ul>
</div>
</div>


CSS:

.l_tabs {
background: #474544 none repeat scroll 0 0;
display: block;
height: 57px;
overflow: auto;
white-space: nowrap;
width: 500px;
}
.l_tabs > div {
background-color: white;
height: 40px;
padding-top: 4px;
width: 100%;
}

Answer

You don't provide the CSS for the li, but I guess there's a float assigned to it, that's why the div stacked to bottom, you need to remove it and apply display: inline-block instead.

.tab-add,
.contentTab {
    float: none;
    display: inline-block;
}