Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set space between two flexbox

I am using material design flexbox layout and in a box, I have two boxes. I create on jsfiddle, to clarify what I mean:

Angular Material app

I want to set between these boxes a space

<div flex layout="row" layout-align="space-between center">
            <md-toolbar flex="15">
                 <h2 class="md-toolbar-tools">
                    <span>Home</span>
                  </h2>

            </md-toolbar>
                <!--How to set space between -->
            <md-toolbar>
                 <h2 class="md-toolbar-tools" layout-align="end center">
                    <span>Sign Up</span>
                    <span>Sign In</span>
                  </h2>

            </md-toolbar>
        </div>
like image 380
softshipper Avatar asked Mar 10 '15 09:03

softshipper


3 Answers

For those interested in a solution using Angular Flex Layout, you can achieve this with fxLayoutGap directive.

Without fxLayoutGap

<div fxLayout="row">
   <div>1. One</div> <div>2. Two</div> <div>3. Three</div> <div>4. Four</div>
</div>

enter image description here

With fxLayoutGap

<div fxLayout="row" fxLayoutGap="20px">
  <div>1. One</div> <div>2. Two</div> <div>3. Three</div> <div>4. Four</div>
</div>

enter image description here

like image 173
Arthur Silva Avatar answered Oct 22 '22 11:10

Arthur Silva


I think what you need is 'layout-margin' https://material.angularjs.org/latest/layout/options

<div layout="row" layout-margin>
  <div flex>Parent layout and this element have margins.</div>
</div>
like image 26
SmoveBB Avatar answered Oct 22 '22 12:10

SmoveBB


I think you can do it much simpler:

<md-toolbar>
    <div class="md-toolbar-tools">
        <span>Home</span>
        <span flex></span>
        <div>
            <span>Sign Up</span>
            <span>Sign In</span>
        </div>
    </div>
</md-toolbar>

You can insert flexible element between HOME and SIGNUP elements and it will fill the space between them.

like image 1
Zhorzh Alexandr Avatar answered Oct 22 '22 10:10

Zhorzh Alexandr