Reputation: 304
i've been struggling all day with this...
i'm try to skin an existing control with CSS, for reasons of product QA, i dont want to edit the code that generates the tabs.
the control is a tabs control that is dynamically generated HTML...
i want all the tabs in a single row... which is fine... but when it reaches the edge of the container... i want all the child tabs to squash up and hide or ellipsis any text over flow.
what i've got -
----------------------------------------
|tab1 |tab2 |tab |tab <- container edge with tab 4 hidden.
what i want -
|tab1 |tab2 |tab 3 |tab 4 |tab x |
or -
|ta...|ta...|ta...|ta...|ta...|ta...|ta... you get the idea...?
the html is spans in a div... like snakes on a plane...
<div>
<span>tab1</span>
<span>tab2</span>
...
<span>tabx</span>
</div>
any hope?
thanks
edit: gotta work in IE7 :'(
Upvotes: 1
Views: 3477
Reputation: 71150
Have a look at this fiddle- it should solve everything you've asked for
HTML
<div>
<span>tab1</span>
<span>tab2</span>
<span>tabx</span>
</div>
CSS
div {
display: table;
table-layout: fixed;
width: 100%;
max-width: 100%;
}
span {
border: 1px solid grey;
padding: 0 20;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
display: table-cell;
}
Upvotes: 2
Reputation: 15881
simple add this CSS :
div{width:100%}
div > span {
float:left;
width:40px; //customise width as per your purpose, can be in %ge too!
overflow:hidden; //hides extra text
white-space:nowrap //avoid getting on new line
}
fix width will give the area to limit to, hope this helps!! :)
Upvotes: 0