6

1) I am trying to stretch the children divs to 60% and align it in the center but it is not working. I am using flex to stretch the size of the div to 60%. See example http://plnkr.co/edit/eaLjJDbjL1KnOI4jLYyO?p=preview

<div layout="column" layout-align="center">
<div style="background-color:#00A000;height: 40px;" flex="60">

</div>

<div style="background-color:#004444;height: 40px;" flex="60">

</div>

<div style="background-color:#0077b3;height: 40px;" flex="60">

</div>

2) In Angularjs Material document it is mentioned that "to customize the size and position of elements in a layout, use flex, offset, and flex-order attributes", I don't see an example of offset.

2 Answers 2

17

This is what you need to do..

<div layout="column" layout-align="center">
    <div layout="row" layout-align="center center">
      <div style="background-color:#00A000;height: 40px;" flex="60">
      </div>  
    </div>
    <div layout="row" layout-align="center center">
      <div style="background-color:#004444;height: 40px;" flex="60">
      </div>
    </div>
    <div layout="row" layout-align="center center">
      <div style="background-color:#0077b3;height: 40px;" flex="60">
      </div>
    </div>
</div>

Read more about layout here

Sign up to request clarification or add additional context in comments.

2 Comments

Sadly, the reference link that you provided is broken, and I can't find this documentation anywhere in their official docs now.
Layout documentation is on the left-menu under Api Reference -> Layout. And i have updated the link also.
1

+1 for nitins answer. It really helped me with my issue. Here is the plunker showing his answer in a different way using angular material cards.

The html:

<section class="content-section gridListdemoBasicUsage">
  <div class="row">
    <div class="col-sm-8 col-sm-offset-2">
      <h1 class="text-center">The Different Ways SharePoint can help define your business</h1>
      <!-- Separator -->
      <md-divider ng-style="{'background': 'rgba(255, 102, 51, 0.7)'}"></md-divider>
    </div>
  </div>
  <div layout="row" layout-align="center" data-ng-style="{'width': '100%'}">
    <div class='md-padding' layout="row" layout-align="center" layout-wrap>
      <md-card class="md-whiteframe-9dp" data-ng-style="{'width': '350px', 'border-radius': '6px'}" data-ng-repeat="card in spcVM.serviceCards" layout-padding>
        <a data-ng-if="card.imagePath" ui-sref="{{card.link}}"><img layout-fill src="{{card.imagePath}}" class="img-rounded" alt="{{card.imageAlt}}" /></a>
        <md-card-content>
          <div>
            <h4>{{card.title}}</h4>
            <md-divider ng-style="{'background': 'rgba(255, 102, 51, 0.7)'}"></md-divider>
            <br />
            <p>{{card.mainContent}}</p>
          </div>
        </md-card-content>
        <md-card-footer>
          <div class="md-actions" layout="row" layout-align="center end">
            <md-button ng-click="card.action($event)">View</md-button>
          </div>
        </md-card-footer>
      </md-card>
    </div>
  </div>
</section>

The above is in a container-fluid div.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.