I am trying to create a CSS fluid tab menu with a variable number of tabs (similar to what you can see on Windows, where the tabs expand depending on the length of the contained header, see below).

Here is an example, I have a setting (I need to save the structure of the element):
<div class="test"> <div class="element"> <h3> <span class="dummy-a"> <span class="dummy-ui-btn-inner"> <span class="dummy-ui-btn-text">very long text is this</span> </span> </span> </h3> </div> <div class="element"> <h3> <span class="dummy-a"> <span class="dummy-ui-btn-inner"> <span class="dummy-ui-btn-text">Two</span> </span> </span> </h3> </div> <div class="element"> <h3> <span class="dummy-a"> <span class="dummy-ui-btn-inner"> <span class="dummy-ui-btn-text">Three</span> </span> </span> </h3> </div> <div class="element"> <h3> <span class="dummy-a"> <span class="dummy-ui-btn-inner"> <span class="dummy-ui-btn-text">Four</span> </span> </span> </h3> </div> <div class="element"> <h3> <span class="dummy-a"> <span class="dummy-ui-btn-inner"> <span class="dummy-ui-btn-text">Five</span> </span> </span> </h3> </div> </div>
And CSS:
.test { width: 100%; display: table; } .test .element { border: 1px solid red; float: left; min-width: 19%; } .test .element.prelast { border: 1px solid green; } .test .element.last { float: none !important; overflow: hidden; } .test .element h3 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
This will create the following:

When I squeeze the screen, the menu is divided into several lines, with the last element filling the remaining width:

My problem is expanding the elements in the "first line" to cover the available space after breaking the menu. Just setting min-width: 19% is a problem, but I can't get anything to work.
Question :
How can I make elements in a โlineโ (this is not really a line if it is split into several lines) occupy all the free space using only CSS?
EDIT :
Here is a sample page showing what I mean. Shorten the browser window and see how the elements behave. I am looking for a way to make the first line expand to the full width AFTER breaking a few lines.
UPDATE :
I updated the sample page. See here . I have no problem expanding the elements as long as they are all "on the same line." The problem begins when the line is "split" into several lines. I would like to know if it is possible to fill the top right space by making the elements expand across the screen.
Here are two more screenshots.

Therefore, the space next to the Four should be closed

Now the space next to the Three should close. You can see that this does not work by setting something to the Four element, because it will not always be in the upper right position. Rather, it should be a CSS rule that I set for all elements (I think).
Also, if this can be easily done using Javascript / Jquery, would I also listen to ideas?
Thanks for the help!