- Material Design Lite 教程
- MDL - 首页
- MDL - 概述
- MDL - 环境设置
- MDL - 布局
- MDL - 网格
- MDL - 标签页
- MDL - 页脚
- MDL - 徽章
- MDL - 按钮
- MDL - 卡片
- MDL - 进度条
- MDL - 加载动画
- MDL - 菜单
- MDL - 滑块
- MDL - 复选框
- MDL - 单选按钮
- MDL - 图标
- MDL - 开关
- MDL - 数据表格
- MDL - 文本字段
- MDL - 工具提示
- Material Design Lite 资源
- MDL - 快速指南
- MDL - 有用资源
- MDL - 讨论
Material Design Lite - 卡片
MDL 提供一系列 CSS 类,用于应用各种预定义的视觉和行为增强功能,并显示不同类型的卡片。下表列出了可用的类及其效果。
序号 | 类名及描述 |
---|---|
1 | mdl-card 将 div 元素标识为 MDL 卡片容器,在“外部”div 上需要。 |
2 | mdl-card--border 在其应用到的卡片部分添加边框,用于“内部”div。 |
3 | mdl-shadow--2dp 到 mdl-shadow--16dp 为卡片设置可变的阴影深度 (2、3、4、6、8 或 16),可选,位于“外部”div;如果省略,则不显示阴影。 |
4 | mdl-card__title 将 div 标识为卡片标题容器,在“内部”标题 div 上需要。 |
5 | mdl-card__title-text 为卡片标题设置适当的文本特性,在标题 div 内的标题标签 (H1 - H6) 上需要。 |
6 | mdl-card__subtitle-text 为卡片副标题设置文本特性,可选。它应该是标题元素的子元素。 |
7 | mdl-card__media 将 div 标识为卡片媒体容器,在“内部”媒体 div 上需要。 |
8 | mdl-card__supporting-text 将 div 标识为卡片正文文本容器,并为正文文本分配适当的文本特性,在“内部”正文文本 div 上需要;文本直接位于 div 内,没有中间容器。 |
9 | mdl-card__actions 将 div 标识为卡片操作容器,并为操作文本分配适当的文本特性,在“内部”操作 div 上需要;内容直接位于 div 内,没有中间容器。 |
示例
以下示例将帮助您了解 mdl-tooltip 类的用法,以显示不同类型的工具提示。
mdl_cards.htm
<html> <head> <script src = "https://storage.googleapis.com/code.getmdl.io/1.0.6/material.min.js"> </script> <link rel = "stylesheet" href = "https://storage.googleapis.com/code.getmdl.io/1.0.6/material.indigo-pink.min.css"> <link rel = "stylesheet" href = "https://fonts.googleapis.com/icon?family = Material+Icons"> <style> .wide-card.mdl-card { width: 512px; } .square-card.mdl-card { width: 256px; height: 256px; } .image-card.mdl-card { width: 256px; height: 256px; background: url('html5-mini-logo.jpg') center / cover; } .image-card-image__filename { color: #000; font-size: 14px; font-weight: bold; } .event-card.mdl-card { width: 256px; height: 256px; background: #3E4EB8; } .event-card.mdl-card__title { color: #fff; height: 176px; } .event-card > .mdl-card__actions { border-color: rgba(255, 255, 255, 0.2); display: flex; box-sizing:border-box; align-items: center; color: #fff; } </style> </head> <body> <table> <tr><td>Wide Card with Share Button</td><td>Square Card</td></tr> <tr> <td> <div class = "wide-card mdl-card mdl-shadow--2dp"> <div class = "mdl-card__title"> <h2 class = "mdl-card__title-text">H5</h2> </div> <div class = "mdl-card__supporting-text"> HTML5 is the next major revision of the HTML standard superseding HTML 4.01, XHTML 1.0, and XHTML 1.1. HTML5 is a standard for structuring and presenting content on the World Wide Web. </div> <div class = "mdl-card__actions mdl-card--border"> <a class = "mdl-button mdl-button--colored mdl-js-button mdl-js-ripple-effect"> Learn HTML5</a> </div> <div class = "mdl-card__menu"> <button class = "mdl-button mdl-button--icon mdl-js-button mdl-js-ripple-effect"> <i class = "material-icons">share</i></button> </div> </div> </td> <td> <div class = "square-card mdl-card mdl-shadow--2dp"> <div class = "mdl-card__title"> <h2 class = "mdl-card__title-text">H5</h2> </div> <div class = "mdl-card__supporting-text"> HTML5 is the next major revision of the HTML standard superseding HTML 4.01, XHTML 1.0, and XHTML 1.1. HTML5 is a standard for structuring and presenting content on the World Wide Web. </div> <div class = "mdl-card__actions mdl-card--border"> <a class = "mdl-button mdl-button--colored mdl-js-button mdl-js-ripple-effect"> Learn HTML5</a> </div> <div class = "mdl-card__menu"> <button class = "mdl-button mdl-button--icon mdl-js-button mdl-js-ripple-effect"> <i class = "material-icons">share</i></button> </div> </div> </td> </tr> <tr><td>Image Card</td><td>Event Card</td></tr> <tr> <td> <div class = "image-card mdl-card mdl-shadow--2dp"> <div class = "mdl-card__title mdl-card--expand"></div> <div class = "mdl-card__actions"> <span class = "image-card-image__filename">html5-logo.jpg</span> </div> </div> </td> <td> <div class = "event-card mdl-card mdl-shadow--2dp"> <div class = "mdl-card__title mdl-card--expand"> <h4>HTML 5 Webinar:<br/>June 14, 2016<br/>7 - 11 pm IST</h4> </div> <div class = "mdl-card__actions mdl-card--border"> <a class = "mdl-button mdl-button--colored mdl-js-button mdl-js-ripple-effect"> Add to Calendar</a> <div class = "mdl-layout-spacer"></div> <i class = "material-icons">event</i> </div> </div> </td> </tr> </table> </body> </html>
结果
验证结果。
广告