2017-02-26 2 views
0

Ich versuche, eine zusammenklappbare div (feste Höhe) auf einer Seite voller Höhe mit Flex und Bootstrap 4 (gleiches Problem mit Bootstrap 3) zu haben.Bootstrap 4 & flex und zusammenklappbaren Inhalt auf voller Höhe Seite

Die aktuelle Snippet funktioniert auf Firefox, aber es funktioniert nicht auf Chrome-basierten Browsern: die ursprüngliche Größe des collapsable korrekt ist (100px), aber wenn man es zusammenbrechen, ist es die Größe nicht richtig (0px wenn subresizable Höhe ist 100%, oder proportional zum verfügbaren Platz).

html, body { 
 
    height:100%; 
 
    width: 100%; 
 
} 
 

 
body { 
 
    display: -webkit-box; 
 
    display: -moz-box; 
 
    display: -ms-flexbox; 
 
    display: -webkit-flex; 
 
    display: flex; 
 

 
    flex-flow: column; 
 
} 
 

 
#collapsable { 
 
    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="#collapsable" aria-expanded="false" aria-controls="collapsable">COLLAPSE</button> 
 
    </div> 
 
    </div> 
 
    <div id="collapsable" class="collapse in"></div> 
 

 
</body>

Antwort

2

Für Bootstrap 3, ich glaube, Sie müssen nur sicherstellen, dass #resizable ist display: flex;

#resizable { 
    -webkit-box-flex: 1; 
    -moz-box-flex: 1; 
    -webkit-flex: 1; 
    -ms-flex: 1; 
    flex: 1; 
    background-color: red; 
    display: flex; 
} 

http://www.codeply.com/go/DcioXI4Xwl

In Bootstrap 4, können Sie einfach d-flex util verwenden Klasse.

Verwandte Themen