简体   繁体   中英

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: 99%;
}

Change your width in .l_tabs{ }

width: 500px;

to

width: 100%;

Updated

Check this fiddle for your reference.

That would do it!

Try this:

.l_tabs > div {
    overflow-x: auto;
    white-space: nowrap;
}

Full Code:

.l_tabs {
    background: #474544 none repeat scroll 0 0;
    display: block;
    height: 57px;
    width: 500px;
}



.l_tabs > div {
    background-color: #fff;
    height: 40px;
    padding-top: 4px;
    width: 100%;
    overflow-x: auto;
    white-space: nowrap;
}


.l_tabs li {
  display: inline-block;
  padding: 0 50px;
}

Ref: https://jsbin.com/gogayo/edit?html,css,output

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;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM