The answer to your question is already given here: https://stackoverflow.com/a/18602739/1596547
The collapse plugin adds a class .collapsing
to your element which has a css3 transition. By default the transition changes the height from 0 to (set or auto) so the effect will be vertical. The plugin also sets the height of the element to 0 before the class has been add.
Althought not mentioned in the docs the plugin can do the same for width; set teh width of the element to 0 and add a class. To trigger the plugin to use the width in stead of the height you will have to add an extra class .width
:
<div id="democontent" class="collapse width">
The plugin will check for this class:
Collapse.prototype.dimension = function () {
var hasWidth = this.$element.hasClass('width')
return hasWidth ? 'width' : 'height'
}
Bootstap's CSS doesn't provide a transistion for collapse.width
so you have have to add it like:
.collapse.width {
height: auto;
-webkit-transition: width 0.35s ease;
-moz-transition: width 0.35s ease;
-o-transition: width 0.35s ease;
transition: width 0.35s ease;
}
Example, see also: http://bootply.com/85690
<div class="container">
<div style="height:100px;float:left;background-color:red">
<button data-toggle="collapse" data-target="#democontent">
o<br>
p<br>
e<br>
n<br>
</button>
</div>
<div id="democontent" class="collapse width" style="height:100px;background-color:blue;color:white;">
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
</div>
</div>