Flex container width when flex-flow is set to column wrap in HTML

FlexWeb DevelopmentFront End ScriptsJavascript

If you have a container with flex height & display flex, then follow this if you want the children to be laid in the column.

Make changes in settings:

-webkit-flex-flow: column wrap;

And for this Chrome automatically add space between div and border top. If we do not want to add space automatically, then we can use:

margin-bottom:100%;

This will move the item up 

.flex-container {
   position: fixed;
   height: 80%;//this will change height of flex container to 80%
   padding: 1;
   margin: 1; // this will change margin to 1
   list-style: none;
   border: 7px solid red; // this will change border to solid red
   display: -webkit-box;
   display: -moz-box;
   display: -ms-flexbox;
   display: -webkit-flex;
   display: flex;
   -webkit-flex-flow: column wrap;
   justify-content: flex-start
   align-content: flex-start;
   align-items: flex-start
}
/** Just to show the elements */
body {
   margin: 0;
   padding: 0;
}
.flex-item {
   background: tomato;
   padding: 5px;
   width: 100px;
   height: 100px;
   margin-bottom: 100%;
   line-height: 150px;
   color: white;
   font-weight: bold;
   font-size: 3em;
   text-align: center;
}
<ul class="flex-container">
   <li class="flex-item">1</li>
   <li class="flex-item">2</li>
   <li class="flex-item">3</li>
   <li class="flex-item">4</li>
   <li class="flex-item">5</li>
   <li class="flex-item">6</li>
</ul>
raja
Published on 11-Apr-2018 13:29:36
Advertisements