1

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 :'(

2 Answers 2

2

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;
}
Sign up to request clarification or add additional context in comments.

3 Comments

that is pretty much it, however the code generates divs and spans... they have id's and stuff , is there a way to style them into <ul> and <li>? perhaps with something like :before and content?? (sorry if this is a bit naive, i've only been at this a week )
Sure, sorry, my bad for replying quickly- I've updated the code jsfiddle.net/L8S9L/1
damn you are boss dude... your solutions looks so much like what i was trying... why the hell didnt mine work?!! :) thanks very much.
0

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!! :)

2 Comments

jsfiddle.net/43fu9 - am i missing something? (it wraps when you squash the window up)
not sure what you are trying to say here....i thought (jsfiddle.net/logintomyk/43fu9/2) this is what you wanted!! :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.