Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get overflow:scroll inside a flex box [duplicate]

Tags:

html

css

flexbox

I have built this layout:

<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>test</title>
<style type="text/css">
html, body{
  margin:0;
  padding:0;
  height:100%;
}
.flex{
  display:flex;
  flex-direction:column;
  min-height:50%;
  width:33.3333%;
  float:left;
  border:1px solid #C8C7CC;
  box-sizing:border-box;
  overflow:scroll;
}
.flex:last-child{
  width:66.6666%;
}
</style>
</head>

<body>
<div class="flex">
    <ul>
        <li>1</li>
        <li>2</li>
        <li>3</li>
        <li>4</li>
        <li>5</li>
        <li>6</li>
        <li>7</li>
        <li>8</li>
        <li>9</li>
        <li>10</li>
        <li>11</li>
        <li>12</li>
        <li>13</li>
        <li>14</li>
        <li>15</li>
        <li>16</li>
        <li>17</li>
        <li>18</li>
        <li>19</li>
        <li>20</li>
        <li>21</li>
        <li>22</li>
        <li>23</li>
        <li>24</li>
        <li>25</li>
    </ul>
</div>
<div class="flex">

</div>
<div class="flex">

</div>
<div class="flex">

</div>
<div class="flex">

</div>
</body>
</html>

I want to put long lists of things inside each flex box. I need them to scroll individually and at the same time fill all the available space in the browser window. I have managed the latter but how can I get a flex box to scroll instead of grow when overflowed?

like image 878
Demiurgen Avatar asked Jul 08 '15 12:07

Demiurgen


1 Answers

I kept on searching after posting this question and I found this post: Flexbox and vertical scroll in a full-height app using NEWER flexbox api

It suggested setting the parent elements height to 0. I tried it and it seems to be working :D

like image 173
Demiurgen Avatar answered Sep 21 '22 05:09

Demiurgen