Alright everyone, is there a way to have 2 divs taking up 50% of the screen and have a bar in the middle so you can drag it and make the left 40% and the right 60% and vice versa.
I hope to be able to do this jquery.
Alright everyone, is there a way to have 2 divs taking up 50% of the screen and have a bar in the middle so you can drag it and make the left 40% and the right 60% and vice versa.
I hope to be able to do this jquery.
Here's a method which I quickly wrote, this does not use jQuery though.
I don't recommend you use that on your website, instead learn from it or improve so that it is completely stable. But hopefully that gives you an idea on how to tackle this problem.
Also there's a bug in IE where, after sliding, it does not lose focus from the slider div. So this means that when you re-slide it, it doesn't release properly. To avoid this: after initial sliding, focus something else, and then slide again. Other then that it works fine.
Hopefully this was helpful in some way :)
What you're describing is commonly referred to as a Spliter. Judging by the demo, this jQuery plugin looks like it does exactly what you want.
Insead of doing css percentages, I would find the width of the window, split it in half (minus bar width), and set pixel widths. this makes it easier to change when the bar is moved.
I don't have a complete answer for you, but one thing that might be worth a look is the Resizable interaction from jQuery's UI: http://jqueryui.com/demos/resizable/#synchronous-resize
It will largely depend on how you want the final product to work. You can probably set it up so that one DIV is resizable, and the adjacent one is just filling the gap.
This may be WAY overkill depending what else your application UI needs are, but ExtJS does this sort of thing very well.
One other unconventional option that should be mentioned: a frameset. Frames were the darling of the mid-90s, but they are still supported by just about every browser without much fuss.