I'm creating a web application that should be responsive. In order to visualize it a bit more, I'm currently recreating the OfficeUI ribbon as Microsoft use in their products, but then for web applications.
In the ribbon, when you have all the tabs on the screen, you see something like:
Now, when you resize the window so that all the tabs aren't visible anymore, you see the following:
You can clearly see the difference, it's a button on the right side for navigating over all the various tabs.
Now, the button will be always placed on the website, but just hidden, and through some JavaScript function, I'll make it visible.
But right now, how need to know at which point I need to make the button visible.
Assume the following simple unordered list:
<ul>
<li>Tab 1</li>
<li>Tab 2</li>
<li>Tab 3</li>
<li>Tab 1</li>
<li>Tab 2</li>
<li>Tab 3</li>
<ul>
All the LI elements are placed next to eachother, just as in the provided images, and if I resize the window to a width that all the LI elements doesn't fit the container, then the next element is pushed down. I know this can be solved with overflow and white-space but that isn't the question here.
I need a JavaScript function to execute a function only and only when the 6 LI elements doesn't fit their container anymore.
Here's a fiddle to give it a try.
I hope that anyone can give me some guidance.
element on page load and save it to a global variable. Then on resize, compare the window width to the global variable - if the window width is less than or equal to the global variable, trigger your function.
– sideroxylon Mar 05 '15 at 10:55