设计需求:设计一个登陆页面

    

1 模块导入

  1.1 将MdCardModule和MdButtonModule模块导入到共享模块中

    

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import {
MdSidenavModule,
MdToolbarModule,
MdIconModule,
MdButtonModule,
MdIconRegistry,
MdCardModule,
MdInputModule
} from '@angular/material';
import { HttpModule } from '@angular/http'; @NgModule({
imports: [
CommonModule,
HttpModule,
MdSidenavModule,
MdToolbarModule,
MdIconModule,
MdButtonModule,
MdCardModule,
MdInputModule
],
declarations: [],
exports: [
CommonModule,
MdSidenavModule,
MdToolbarModule,
MdIconModule,
MdButtonModule,
HttpModule,
MdCardModule,
MdInputModule
]
})
export class SharedModule { }

  1.2 将material依赖的动画模块通过cnpm进行下载,并将动画模块导入到核心模块中

    cnpm install --save @angular/animation

    

import { NgModule, Optional, SkipSelf } from '@angular/core';
import { SharedModule } from '../shared/shared.module';
import { HeaderComponent } from './header/header.component';
import { FooterComponent } from './footer/footer.component';
import { SidenavComponent } from './sidenav/sidenav.component'; import { DomSanitizer } from '@angular/platform-browser';
import { MdIconRegistry } from '@angular/material';
import { loadSvgResources } from '../utils/loadSvgResources' import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; @NgModule({
imports: [
SharedModule,
BrowserAnimationsModule
],
declarations: [
HeaderComponent,
FooterComponent,
SidenavComponent
]
,
exports: [
HeaderComponent,
FooterComponent,
SidenavComponent
]
})
export class CoreModule {
constructor(
@Optional() @SkipSelf() parentModule: CoreModule,
mdIconRegistry: MdIconRegistry,
domSanitizer: DomSanitizer
) {
if (parentModule) {
throw new Error('CoreModule模块已经存在,请尽在主模块中进行引入。')
}
loadSvgResources(mdIconRegistry, domSanitizer);
}
}

  技巧01:其他模块如果需要用到MdCardModule和MdButtonModule时只需要导入共享模块即可

  技巧02:核心模块在angualr应用只加载一次而且是在项目启动时加载的,共享模块可以加载多次

2 md-card组件详解

  2.1 md-card组件主要结构

<md-card>
<md-card-header>
<md-card-title>主标题</md-card-title>
<md-card-subtitle>副标题</md-card-subtitle>
</md-card-header>
<md-card-content>内容</md-card-content>
<md-card-actions>行为</md-card-actions>
<md-card-footer>页脚</md-card-footer>
</md-card>

3 MdButtonModule详解

  3.1 MdButtonModule模块中按钮的形式

    3.1.1 普通按钮:md-button md-raised-button md-icon-button

    3.1.2 浮动按钮: md-fab md-mini-fab

  3.2 MdButtonModule模块中按钮的使用规则

    

<button md-button>普通按钮</button>
<br />
<button md-raised-button>提升按钮</button>
<br />
<!-- 图标按钮:需要导入MdIconModule图标模块,而且还需要在主页面引入谷歌的图标库 -->
<button md-icon-button><md-icon>menu</md-icon></button>
<br />
<button md-fab >浮动按钮</button>
<br />
<button md-mini-fab>小型浮动按钮</button>

  技巧02:谷歌字体图标库镜像引用             ->        <link href="//lib.baomitu.com/material-design-icons/3.0.1/iconfont/material-icons.min.css" rel="stylesheet">

4 MdCardModule 、 MdButtonModule 、 MdInputModule综合应用

  4.1 导入这三个模块

  4.2 下载依赖的动画模块

  4.3 在登录组件中使用者三个模块提供的组件完成设计

    

<form>
<md-card>
<md-card-header>
<md-card-title>登录模块</md-card-title>
<md-card-subtitle>登录信息录入并提交</md-card-subtitle>
</md-card-header>
<md-card-content>
<md-input-container class="full-width">
<span mdPrefix>XiangXu.</span>
<input mdInput type="text" placeholder="请输入你的邮箱" />
<span mdSuffix>@163.com</span>
</md-input-container>
<md-input-container class="full-width">
<input mdInput type="password" placeholder="请输入你的密码" />
</md-input-container>
<button md-raised-button type="button">登录</button>
</md-card-content>
<md-card-actions class="text-right">
<p>还未注册?&nbsp;<a href="">立即注册</a></p>
<p>忘记密码?&nbsp;<a href="">找回密码</a></p>
</md-card-actions>
<!-- <md-card-footer>页脚</md-card-footer> -->
</md-card> <md-card>
<md-card-header>
<md-card-title>每日佳句</md-card-title>
<md-card-subtitle>Do not aim for your success if you really want it. Just stick to do what you love and believe in.</md-card-subtitle>
</md-card-header>
<img md-card-image src="/assets/img/car.jpg" />
<md-card-content>少一些功利主义的追求,多一些不为什么的坚持。</md-card-content>
</md-card>
</form>

  4.4 在全局CSS文件中设置

    充满整行的样式

      

/* You can add global styles to this file, and also import other style files */
@import '~@angular/material/prebuilt-themes/deeppurple-amber.css'; // 导入material的内建主体
html, body, app-root, md-sidenav-container, .site {
width: 100%;
height: 100%;
margin: 0;
} .site {
display: flex;
flex-direction: column;
}
header {
// background-color: skyblue;
}
main {
flex: 1;
}
footer {
// background-color: skyblue;
} .fill-remaining-space { // flex项目自动填充多余空间
flex: 1 1 auto;
} .full-width {
width: 100%;
}

  4.5 在登录组件的CSS文件中设置

    将form元素设置成flex容器

    md-card组件宽度和高度

    文本向右对齐

      

form {
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
width: 100%;
height: 100% ; } md-card {
height: 24em;
flex: 0 0 20em;
} .text-right {
text-align: end;
margin: 10px;
} // form {
// display: flex;
// flex-direction: row;
// justify-content: center;
// align-items: center;
// width: 100%;
// height: 100%;
// } // md-card {
// height: 24em;
// flex: 0 0 20em;
// } // .text-right {
// margin: 10px;
// text-align: end;
// }

Material使用04 MdCardModule和MdButtonModule综合运用的更多相关文章

  1. Material04 MdCardModule和MdButtonModule综合运用

    设计需求:设计一个登陆页面 1 模块导入 1.1 将MdCardModule和MdButtonModule模块导入到共享模块中 import { NgModule } from '@angular/c ...

  2. Material使用03 MdCardModule模块、MdInputModule模块

    需求:先需要增加一个登录模块 1 创建登录模块 ng g m testLogin 1.1 将共享模块导入到登录模块中 import { NgModule } from '@angular/core'; ...

  3. 优化MySchool数据库设计之【巅峰对决】

    优化MySchool数据库设计 之独孤九剑 船舶停靠在港湾是很安全的,但这不是造船的目的 By:北大青鸟五道口原玉明老师 1.学习方法: 01.找一本好书 初始阶段不适合,可以放到第二个阶段,看到知识 ...

  4. 让CKEditor支持FLV视频播放

    平时都是做C/S开发,最近需要维护一个协会门户网站. 文章编辑使用CKEditor 3.3.2 + ckfinder 2.0的方案.可是这种方案居然不支持FLV视频播放,度娘说以前的老版本是支持的,这 ...

  5. 万能的 SQL编程

    简介:T-SQL语句创建库.创建表和听.和添加约束等.T-SQL是数据库结构化查询语言,常见的增加.删出.修改.查询.创建库和创建表的语句,还支持定义变量.输出语句.逻辑控制语句(IF.CASE.WH ...

  6. IIS 发布mvc 403.14

    转载: iis7 发布mvc3 遇到的HTTP错误 403.14-Forbidden Web 服务器被配置为不列出此目录的内容及Login on failed for “IIS APPPOOL\ASP ...

  7. Linux(Centos)下jdbc连接oracle速度超慢的问题

    最近在centos下写个java swing程序,发现在linux用jdbc连接oracle及其缓慢,还经常失败.但是同样的程序在windows下运行就连接的非常快.网上搜索了很长时间都和我这情况没关 ...

  8. XAF 如何从Excel复制多个单元格内容到GridView(收藏)

    XAF 如何从Excel复制多个单元格内容到GridView 2012年04月11日 ⁄ 综合 ⁄ 共 10998字 ⁄ 字号 小 中 大 ⁄ 评论关闭 how to paste some excel ...

  9. 问题:部署到iis上后Chart图片不显示;结果:使用webchart过程中遇到的一些问题

    使用webchart过程中遇到的一些问题 2013年04月30日 ⁄ 综合 ⁄ 共 4874字 ⁄ 字号 小 中 大 ⁄ 评论关闭   安装条件:1.操作系统如果是2003的,那么需要到sp2补丁2. ...

随机推荐

  1. 转的es6 =>函数

    原文地址 箭头函数=>无疑是ES6中最受关注的一个新特性了,通过它可以简写 function 函数表达式,你也可以在各种提及箭头函数的地方看到这样的观点--"=> 就是一个新的 ...

  2. Linux上网设置

    ifconfig 命令查看网络设置 步骤1.配置/etc/sysconfig/network-scripts/ifcfg-eth0 里的文件.有的是(ifcfg-ens33) 文件 CentOS下的i ...

  3. 使用JobControl控制MapReduce任务

    代码结构 BeanWritable:往数据库读写使用的bean ControlJobTest:JobControl任务控制 DBInputFormatApp:将关系型数据库的数据导入HDFS,其中包含 ...

  4. C++ Const 使用总结,代码实例亲测

    1. 修饰普通变量 修饰变量语法 const TYPE value  <==> TYPE const value 两者等价, 变量不可修改,无需说明. 2. 修饰指针 首先看下面一段 代码 ...

  5. java备份和恢复数据代码例子

    import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.F ...

  6. .net Core 相关问题

    1.Vs中注释生成xml文档文件 项目->属性->生成->输出->勾选“XML文档文件”->保存  就完成. 保存后出现没有勾选情况,直接用txt打开.csproj文件加 ...

  7. 代码题(1)—lower_bound和upper_bound算法

    1.lower_bound:查找序列中的第一个出现的值大于等于val的位置 这个序列中可能会有很多重复的元素,也可能所有的元素都相同,为了充分考虑这种边界条件,STL中的lower_bound算法总体 ...

  8. Java微信开发_Exception_03_errcode:48001 errmsg:api unauthorized hint

    创建菜单时出现这个异常, 异常信息:errcode:48001 errmsg:api unauthorized hint 解读:调用的接口没有权限. 回去公众号后台一看,发现真的没有自定义菜单的权限, ...

  9. PHP中怎样让数组以字母为键值来递增

    //小写字母 $key = 97; $arr = array(); for($i=1;$i<=26;$i++){ $arr[chr($key)] = $i; $key++; } print_r( ...

  10. utc时间、本地时间及时间戳转化

    1.时间戳的概念 时间戳的定义请看百科unix时间戳,需要注意的时间戳为当前时刻减去UTC时间(1970.1.1)零点时刻的秒数差,与当前系统所处的时区无关,同一时刻不管在任何时区下得到的时间戳都是一 ...