Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use flex-grow?

In the doc and in the issues of Bootstrap v4 (here), I can't see any plan on supporting flex-grow, something with a syntax like this for example:

<div class="d-flex">       <div  class="flex-grow">         I use all the space left       </div>       <div>         I am a small text on the right       </div> </div> 

Here a sample of the layout I'd like to create:

image

The export button is always on the right, and the navigation button takes all the space left and therefore looks clean.

Is it possible to build such a layout already? Maybe it is not advised? Of course, there are workarounds using CSS, but I am looking for a clean solution, ideally using Bootstrap class names only to guarantee consistency.

like image 399
Eric Burel Avatar asked Feb 09 '17 17:02

Eric Burel


People also ask

How does flex grow works?

The flex-grow property specifies how much the item will grow relative to the rest of the flexible items inside the same container. Note: If the element is not a flexible item, the flex-grow property has no effect.

Does Flex grow affect height?

It has no affect on height.

How do you use Flex-shrink and grow?

Flex-shrink is the opposite of flex-grow, determining how much a square is allowed to shrink. It only comes into play if the elements must shrink to fit into their container — i.e. when the container is just too small. Its main use is to specify which items you want to shrink, and which items you don't.

How do you grow flex items?

The flex-grow property is a sub-property of the Flexible Box Layout module. It defines the ability for a flex item to grow if necessary. It accepts a unitless value that serves as a proportion. It dictates what amount of the available space inside the flex container the item should take up.


1 Answers

use .col for a simple flex-grow: 1;. It's described here https://v4-alpha.getbootstrap.com/layout/grid/#variable-width-content

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet" />  <div class="container">    <div class="row">      <div class="col">        I use all the space left      </div>      <div class="col-sm col-sm-auto">        I am a small text on the right      </div>    </div>  </div>
like image 158
Michael Coker Avatar answered Sep 29 '22 13:09

Michael Coker