I have a webpage which has two main divs. One for a small 'control panel' on the left (takes up a quarter of the space), and a larger main table on the right (takes up three quarters of space). To accommodate different screen sizes, I've incorporates boostrap columns e.g. <div className="control-panel col-lg-3 col-md-3 col-sm-3 col-xs-3" id="control-panel">
This mostly works. If I dynamically resize the browser, this is as expected.
Moving on, I've created a toggle button whose click event hides this control panel div (and is expected to resize the main table from 9 columns to the full 12 columns).
Right now for the resizing of the main table, in the click function i just have:
This will toggle between 9 column width and 12, but this will only work on a large screen that isn't resized.
If I dynamically resize the browser to anything else, this will not work.
My assumption is I need some way to toggle multiple screen combos like:
<div class="row"> <div class="col-xs-9 master-panel"> I am the master </div> <div class="col-xs-3 control-panel"> I am the control panel </div> </div> <button class="btn btn-primary">Toggle</button>
What would need to be done if they're not all 12:9? For example, stretching the browser too much (e.g. over two screens) makes the control panel look too large and bulky so for lg it may need to be reduced to 2 or 1
Julian Hansen
Then we would probably need to look at a solution that adds and removes classes manually rather than using toggle class.
I've seen example code that replaces toggleclass with some sort of add/removeclass. They're usually used in conjunction with if statements. But then surely that would be no different to my previous example? It won't work when dynamically resizing the browser window. It'll only work when you stop resizing the window and then refresh the page
it seems the toggle class originally used was actually working, but a JQuery somewhere else was interfering. Once I commented it out, it worked. Thanks for the help
CSS
Open in new window
HTMLOpen in new window
jQueryOpen in new window
Working sample here