- Angular Material - Discussion
- Angular Material - Useful Resources
- Angular Material - Quick Guide
- Angular Material - WhiteFrame
- Angular Material - Virtual Repeat
- Angular Material - Typography
- Angular Material - Toasts
- Angular Material - Themes
- Angular Material - Switches
- Angular Material - Swipe
- Angular Material - Subheaders
- Angular Material - Fab Speed Dial
- Angular Material - SideNav
- Angular Material - Grids
- Angular Material - Icons
- Angular Material - Inputs
- Angular Material - Layouts
- Angular Material - Widgets
- Angular Material - Cards
- Angular Material - Bottom Sheet
- Angular Material - Autocomplete
- Environment Setup
- Angular Material - Overview
- Angular Material - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Angular Material - Layouts
Layout Directive
Layout directive on a container element is used to specify the layout direction for its children. Following are the assignable values for the Layout Directive −
row − Items are arranged horizontally with max-height = 100% and max-width is the width of the items in the container.
column − Items are arranged vertically with max-width = 100% and max-height is the height of the items in the container.
For responsive design such as layout to be automatically changed depending upon the device screen size, the layout APIs psted in the following table can be used to set the layout direction for devices with view widths.
Sr.No | API & Device width when breakpoint overrides default |
---|---|
1 | layout Sets default layout direction unless overridden by another breakpoint. |
2 | layout-xs width < 600px |
3 | layout-gt-xs width >= 600px |
4 | layout-sm 600px <= width < 960px |
5 | layout-gt-sm width >= 960px |
6 | layout-md 960px <= width < 1280px |
7 | layout-gt-md width >= 1280px |
8 | layout-lg 1280px <= width < 1920px |
9 | layout-gt-lg width >= 1920px |
10 | layout-xl width >= 1920px |
Example
The following example shows the use of layout directive and also the uses of layout.
am_layouts.htm
<html lang = "en"> <head> <pnk rel = "stylesheet" href = "https://ajax.googleapis.com/ajax/pbs/angular_material/1.0.0/angular-material.min.css"> <script src = "https://ajax.googleapis.com/ajax/pbs/angularjs/1.4.8/angular.min.js"></script> <script src = "https://ajax.googleapis.com/ajax/pbs/angularjs/1.4.8/angular-animate.min.js"></script> <script src = "https://ajax.googleapis.com/ajax/pbs/angularjs/1.4.8/angular-aria.min.js"></script> <script src = "https://ajax.googleapis.com/ajax/pbs/angularjs/1.4.8/angular-messages.min.js"></script> <script src = "https://ajax.googleapis.com/ajax/pbs/angular_material/1.0.0/angular-material.min.js"></script> <pnk rel = "stylesheet" href = "https://fonts.googleapis.com/icon?family=Material+Icons"> <style> .box { color:white; padding:10px; text-apgn:center; border-style: inset; } .green { background:green; } .blue { background:blue; } </style> <script language = "javascript"> angular .module( firstApppcation , [ ngMaterial ]) .controller( layoutController , layoutController); function layoutController ($scope) { } </script> </head> <body ng-app = "firstApppcation"> <span id = "layoutContainer" ng-controller = "layoutController as ctrl" style = "height:100px;" ng-cloak> <span layout = "row" layout-xs = "column"> <span flex class = "green box">Row 1: Item 1</span> <span flex = "20" class = "blue box">Row 1: Item 2</span> </span> <span layout = "column" layout-xs = "column"> <span flex = "33" class = "green box">Column 1: item 1</span> <span flex = "66" class = "blue box">Column 1: item 2</span> </span> </span> </body> </html>
Result
Verify the result.
Flex Directive
The flex directive on a container element is used to customize the size and position of the elements. It defines the way how the element is to adjust its size with respect to its parent container and the other elements within the container. Following are the assignable values for the flex directive −
multiples of 5 − 5, 10, 15 ... 100
33 − 33%
66 − 66%
Example
The following example shows the use of the flex directive and also the uses of flex.
am_flex.htm
<html lang = "en"> <head> <pnk rel = "stylesheet" href = "https://ajax.googleapis.com/ajax/pbs/angular_material/1.0.0/angular-material.min.css"> <script src = "https://ajax.googleapis.com/ajax/pbs/angularjs/1.4.8/angular.min.js"></script> <script src = "https://ajax.googleapis.com/ajax/pbs/angularjs/1.4.8/angular-animate.min.js"></script> <script src = "https://ajax.googleapis.com/ajax/pbs/angularjs/1.4.8/angular-aria.min.js"></script> <script src = "https://ajax.googleapis.com/ajax/pbs/angularjs/1.4.8/angular-messages.min.js"></script> <script src = "https://ajax.googleapis.com/ajax/pbs/angular_material/1.0.0/angular-material.min.js"></script> <pnk rel = "stylesheet" href = "https://fonts.googleapis.com/icon?family=Material+Icons"> <style> .box { color:white; padding:10px; text-apgn:center; border-style: inset; } .green { background:green; } .blue { background:blue; } </style> <script language = "javascript"> angular .module( firstApppcation , [ ngMaterial ]) .controller( layoutController , layoutController); function layoutController ($scope) { } </script> </head> <body ng-app = "firstApppcation"> <span id = "layoutContainer" ng-controller = "layoutController as ctrl" layout = "row" style = "height:100px;" ng-cloak layout-wrap> <span flex = "30" class = "green box"> [flex = "30"] </span> <span flex = "45" class = "blue box"> [flex = "45"] </span> <span flex = "25" class = "green box"> [flex = "25"] </span> <span flex = "33" class = "green box"> [flex = "33"] </span> <span flex = "66" class = "blue box"> [flex = "66"] </span> <span flex = "50" class = "blue box"> [flex = "50"] </span> <span flex class = "green box"> [flex] </span> </span> </body> </html>
Result
Verify the result.
Advertisements