4

i am trying to achieve that, and can't figure how:

|-------------80%---------------------|----20%---|

one row with 2 columns with specific width.

  • i don't understand something, columns (usage in Material) are look to me like rows > in rows
|-------------------------------------|----//---|
|-------------------------------------|----//---|
|-------------------------------------|----//---|

and not like my example.

How can i achieve it?

2 Answers 2

6

After you have imported AngularJS and Angular Material (including the css file), you need to import Angular Material in your AngularJS app. To do this, you need to add the "ngMaterial" provider in your AngularJS module, like this:

var app = angular.module("myApp", ["ngMaterial"]);

(if you skip this part, it won't work).

Then you can write your HTML code as follows

<div layout="row" layout-wrap>
    <div flex="80">80%</div>
    <div flex="20">20%</div>
</div>

This will create a div that will act as a container. It will contain the elements you want to show and they will be aligned in a row and, if necessary, they will be displayed in a second row. In the flex property you can specify the width (as a percentage) of the element compared to the width of the container.

Obviously you can change the name of your Angular module and the number/ width of your html elements as you want.

And there you can see some examples and a bit of documentation

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

11 Comments

Thanks! and what about if i want to add a navigation to page (up menu), how can i set vertical space as the above? (menu of 20% and the rest as 80%) ?
@E.Meir You could simply use a Toolbar. It will be placed in top of the screen and if you add to it the css property position: fixed; it will remain always at the top, also when you scroll a long page. It will also do all the job for you :) Here the demos and the documentation
Thanks! what about <div layout="row" > <div flex="70" **layout-align="end left"**><div flex="30" **layout-align="center end"**> how can i set each of the column to be in specific direction?
@E.Meir If you mean "How to change the alignment?" The answer is easy, simply change the value of the property layout-align. The possible values are shown in the docs
yes i mean that- so what i wrote in my last comment suppose to work? layout-align [roperty suppose to be on a div ?
|
1

First you need to declare:

md-cols Number of columns in the grid.

In your case (8+2=10):

<md-grid-list md-cols="10" ...

Then your items:

<md-grid-tile md-colspan="8">...</md-grid-tile>

<md-grid-tile md-colspan="2">...</md-grid-tile>

Codepen Sample - Angular Material Docs

1 Comment

md-colspan is a property of grid tile and if i don't use grid-list i should use flex?

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.