Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery accordion height:100%

I'm looking to create an accordion style website with 3 menu item that fill 100% of the window when expanded. I can find a lot of different accordions, but none that work properly with height: 100%

Any ideas?

Here is the general layout:

http://i.imgur.com/GLyTX.jpg

http://i.imgur.com/hOUrO.jpg

like image 786
Craig Jonathan Kristensen Avatar asked Jan 28 '12 14:01

Craig Jonathan Kristensen


3 Answers

jQuery( "#accordion" ).accordion({
   collapsible: true,
   heightStyle: "content"
});

It will work and if your are using some combo or widget whose size increases after selection or due to any action the size of the accordion increases than by handling that event you can simply call the following;

jQuery( "#accordion" ).accordion( "resize" );

to adjust your accordion.

like image 193
Imran Butt Avatar answered Oct 31 '22 09:10

Imran Butt


You can do this with jQuery UI Accordion (demo):

css

html, body  {
    height: 100%;
    padding: 0;
    margin: 0;
    overflow: hidden;
}

.accordion {
    height: 100%;
}

script

$(function(){

    $( ".accordion" ).accordion({ fillSpace: true });

    $(window).resize(function(){
        // update accordion height
        $( ".accordion" ).accordion( "resize" )
    });

});

For newer versions of jQuery UI Accordion (v1.12.1+), set the heightStyle to fill, use "refresh" to update and set the html & body height to 100% (demo).

CSS

html,
body {
  height: 100%;
  padding: 0;
  margin: 0;
  overflow: hidden;
}

Script

$(".accordion").accordion({
  heightStyle: "fill"
});

$(window).resize(function() {
  // update accordion height
  $(".accordion").accordion("refresh");
});
like image 8
Mottie Avatar answered Oct 31 '22 09:10

Mottie


I use 1.8.21 of jquery-ui, and heightStyle: "content" didn't work for me. I read through the code and I found the following solution:

    $('.accordion').accordion({
        "autoHeight": false,
    });
like image 2
Marek Kowalski Avatar answered Oct 31 '22 10:10

Marek Kowalski