I'm attempting to create a collapsible div
with a fixed height within a full-height page using flex and bootstrap 4 (also encountering the same issue with bootstrap 3).
The current code snippet functions correctly on Firefox, but encounters a problem on Chrome-based browsers: the initial size of the collapsible
is correct (measuring at 100px
), however, upon collapsing, it does not resize correctly (shrinks to 0px
if subresizable's height is set to 100%
, or shrinks proportionally to the available space).
html, body {
height:100%;
width: 100%;
}
body {
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
flex-flow: column;
}
#collapsible {
height: 100px;
background-color: green;
}
#subresizable {
height: 100%;
width: 100%;
background-color: pink;
}
#resizable {
-webkit-box-flex: 1;
-moz-box-flex: 1;
-webkit-flex: 1;
-ms-flex: 1;
flex: 1;
background-color: red;
}
<header>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</header>
<body>
<div id="resizable">
<div id="subresizable">
<button class="btn btn-primary" type="button" data-toggle="collapse" data-target="#collapsible" aria-expanded="false" aria-controls="collapsible">COLLAPSE</button>
</div>
</div>
<div id="collapsible" class="collapse in"></div>
</body>