27

I'm trying to create the overall layout of a webapp. The app is full-screen and has a fixed header and three columns/panes. The center pane consists of two rows:

app wireframe layout

The panes should be resizable through dragging the pane edges with the mouse (see arrows in image above).

The individual panes have should have vertical scrollbars in case of overflowing content, that is, no global browser window scrollbar.

Using jQuery and jQuery UI Resizable, I've created this (partly working) JSFiddle.

HTML:

<div class="header">
  Fixed header    
</div>
<div class="wrapper">
   <div class="inner-wrapper">
       <div class="left pane">Left</div>
       <div class="center pane">
           <div class="inner">
               <div class="top">Center top</div>
               <div class="bottom">Center bottom</div>
           </div>
       </div>
       <div class="right pane">Right</div>
   </div>
</div>

CSS:

html, body {
    height: 100%;
}
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 20px;
    background-color: moccasin;  
}
.wrapper {
    position:absolute;
    top: 21px;
    right: 0;
    bottom: 0;
    left: 0;
    background-color: fuchsia;
}
.inner-wrapper,
.center.pane .inner {
    display: table;
    width: 100%;
    height: 100%;
}
.pane {
    display: table-cell;
}
.left.pane {
   background-color: olivedrab; 
}
.center.pane {
    background-color: lightblue;
}
.center.pane .inner .top,
.center.pane .inner .bottom{
    display: table-row;  
}
.center.pane .inner .top {
    background-color: lightcoral;   
}
.center.pane .inner .bottom {   
    background-color: orange;
    height: 100%;
    width: 100%;
}
.right.pane {
    background-color: #999;
}

JavaScript:

$(function () {
    $(".left.pane").resizable({
        handles: "e, w"
    });
    $(".right.pane").resizable({
        handles: "e, w"
    });
    $(".center.pane .inner .bottom").resizable({
        handles: "n, s"
    });
});

It has several issues, including:

  • When resizing Left, Right is also resized (which it shouldn't)
  • When resizing Left towards full width, Center content is hidden under Right
  • When resizing Right the wrapper (Fuchsia-colored) is partly visible
  • Center bottom is resized through the top of the Center top, not through it's own top

I'm aware of the jQuery Layout plugin, but as far as I can see, it doesn't offer quite the layout I'm after. Also, I want to keep it as simple as possible.

Furthermore, I have tried Methvins splitter plugin, but couldn't get it to work.

My question:

Any suggestions for how to create a layout as in the image from jQuery UI Resizable and what I have in the JSFiddle?

agibsen
  • 867
  • 2
  • 10
  • 18

7 Answers7

31

There are more appropriate plugins, based on jQuery to obtain what you want.

OPTION 1:

I personally used in a my project UI Layout.

It is an almost old project (6 years ago), but in mid-2014 its development is re-started, even if there are no more information after september 2014.

Actually, last stable version is 1.4.3, released in sept '14. New website is:


OPTION 2:

If you need a more complete solution, you could think about jEasy UI, that is a complete framework that

[...] helps you build your web pages easily

It is a sort of replacement of jQuery UI, with some similar widgets (dialogs, accordions, ...) and something exclusive, like Layout module, already linked in my answer.


OPTION 3: Analogue solution to the previous one, is Zino UI, another complete UI framework that has a specific component dedicated to "Split Layout"


OPTION 4: jQWidgets is another library, with similar purposes of previous ones, and specifically could be interesting jqxSplitter module.


Related alternative (similar):

There is also another alternative, that allows to slice panels in the browser windows but in addition allows to drag&drop single panels creating different tabs, and side-by-side sub-windows.

This is called Golden Layout. It's different from previous ones, for many reasons also more powerful but surely at the moment it has not Touch support...

Luca Detomi
  • 5,564
  • 7
  • 52
  • 77
  • That's actually what we ended up using. – agibsen Apr 08 '14 at 08:45
  • 1
    haahah ok. please, Accept answer clicking on "check mark" if you think that is the most correct :-) – Luca Detomi Apr 08 '14 at 08:47
  • Check up the code of UI Layout, it's pooor documentation, plus over-complex code, a layout lib does not need to be so complex, too many things can be done in css rather using javascript – Kevin Simple Aug 24 '15 at 02:33
  • @KevinSimple Developer clearly wrote 1 year ago that new version based on new technologies (and so, simpler) was in developmente. Since that date no news are come so is unkwown if this project is still in progress or not. – Luca Detomi Aug 31 '15 at 06:40
  • 1
    @LucaDetomi This is an excellent compilation of tool set...thank you. – Apricot May 12 '18 at 17:05
9

There were a few small problems that caused the behaviour that you don't like.

These were fixed in this Fiddle

The problems were:

When resizing Left, Right is also resized (which it shouldn't)

Fixed by setting a initial width (in percent)

When resizing Left towards full width, Center content is hidden under Right

Couldn't reproduce

When resizing Right the wrapper (Fuchsia-colored) is partly visible Center bottom is resized through the top of the Center top, not through it's own top

Fixed by setting left to 0 during resize.

$(".right.pane").resizable({
    handles: "e, w",
    resize: function(event, ui) {
      ui.position.left = 0;
    }
  });

Center bottom is resized through the top of the Center top, not through it's own top

This is due to that JQuery UI Resizable uses relative positioning which do not work in table cells. Fixed by adding a content div that handles the resize.

<div class="top pane"> 
   <div class="top-content">Center top</div>
</div>
Richard Houltz
  • 1,962
  • 1
  • 18
  • 24
  • This solution doesn't seem to support any real amount of content in the panels - see https://jsfiddle.net/Abeeee/x1scokaz/14/ – user1432181 Feb 09 '23 at 11:27
8

I found one which seems acceptable for this requirement, if you looking for something more minimalistic compared to jEasy UI. : )

I'll give it a try. Just wanted to share this, to save others search time, hopefully.

fentas
  • 1,011
  • 12
  • 14
1

i'm usign this plugin with jquery

http://www.bramstein.com/projects/jlayout/jquery-plugin.html

1

I came up with the answer to this myself, although in the end it took me over a year of development! The result is a modern, responsive panel layout widget built using jQuery and jQuery UI widget factory.

http://www.silvercore.co.uk/widgets/propanellayout/

The best solution at the time the question was asked was undoubtedly jQuery UI.Layout, but over time that project has stagnated and the plugin does not work with jQuery 2. Despite the code being released on GitHub its fate is unknown, which makes using it as the foundation of a long term project questionable.

A few of the other links posted here are dead now and if you don't want or need a full application framework your choices are limited.

Stephen Blair
  • 369
  • 2
  • 14
1

OK, hopefully my last edit. Went through a bunch of these, and ended up with jQuery UI layout.

Goldenlayout is nice, but you have to actually add the html in each pane through javascript. If you've got all your stuff in react components I guess this might be fine, but not for my use case.

jQuery UI layout seems to be pretty robust and was just updated in 2014.

Greg Blass
  • 3,523
  • 29
  • 42
  • 1
    Can you post the jQuery UI solution you ended up with please ? – Stephan May 18 '18 at 20:38
  • Hmm, its been a while. Its mixed in with a bunch of commercial code. Hopefully one day I can come back here and help out. Today is not that day unfortunately! – Greg Blass May 19 '18 at 14:49
1

You can use Gridstack It's easy to use and powerful.

bensadiz
  • 13
  • 2