- 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 - 选项卡
Material Design Lite (MDL) 选项卡组件是一个用户界面组件,有助于以独占方式在单个空间中显示多个屏幕。
MDL 提供各种 CSS 类,以将各种预定义的视觉和Behave增强功能应用于选项卡。下表提到了可用的类别及其效果。
| 先生。 | 类名和描述 |
|---|---|
| 1 | MDL 布局 将容器标识为 MDL 组件。外部容器元件上需要。 |
| 2 | MDL 选项卡 将选项卡容器标识为 MDL 组件。“外部”div 元素必需。 |
| 3 | mdl-js-选项卡 将基本 MDL Behave设置为选项卡容器。“外部”div 元素必需。 |
| 4 | mdl-js-涟漪效应 为选项卡链接添加波纹点击效果。选修的; 继续“外部”div 元素。 |
| 5 | mdl-tabs__tab-bar 将容器标识为 MDL 选项卡链接栏。第一个“内部”div 元素需要。 |
| 6 | mdl-tabs__tab 将锚点(链接)标识为 MDL 选项卡激活器。第一个“内部”div 元素中的所有链接都是必需的。 |
| 7 | 活跃 将选项卡标识为默认显示选项卡。在一个(且仅一个)“内部”div(选项卡)元素上是必需的。 |
| 8 | mdl-tabs__面板 将容器标识为选项卡内容。每个“内部”div(选项卡)元素都是必需的。 |
例子
以下示例将帮助您了解如何使用 mdl-tab 类在各种选项卡上布局内容。
下面给出的 MDL 类将在本例中使用 -
mdl-layout - 将 div 标识为 MDL 组件。
mdl-js-layout - 将基本的 MDL Behave添加到外部 div。
mdl-layout--fixed-header - 使标题始终可见,即使在小屏幕中也是如此。
mdl-layout__header-row - 将容器标识为 MDL 标题行。
mdl-layout-title - 标识布局标题文本。
mdl-layout__content - 将 div 标识为 MDL 布局内容。
mdl-tabs - 将选项卡容器标识为 MDL 组件。
mdl-js-tabs - 将基本 MDL Behave设置为选项卡容器。
mdl-tabs__tab-bar - 将容器标识为 MDL 选项卡链接栏。
mdl-tabs__tab - 将锚点(链接)标识为 MDL 选项卡激活器。
is-active - 将选项卡标识为默认显示选项卡。
mdl-tabs__panel - 将容器标识为选项卡内容。
mdl_tabs.htm
<html>
<head>
<link rel = "stylesheet"
href = "https://storage.googleapis.com/code.getmdl.io/1.0.6/material.indigo-pink.min.css">
<script src = "https://storage.googleapis.com/code.getmdl.io/1.0.6/material.min.js">
</script>
<link rel = "stylesheet"
href = "https://fonts.googleapis.com/icon?family=Material+Icons">
</head>
<body>
<div class = "mdl-layout mdl-js-layout mdl-layout--fixed-header">
<header class = "mdl-layout__header">
<div class = "mdl-layout__header-row">
<span class = "mdl-layout-title">Material Design Tabs</span>
</div>
</header>
<main class = "mdl-layout__content">
<div class = "mdl-tabs mdl-js-tabs">
<div class = "mdl-tabs__tab-bar">
<a href = "#tab1-panel" class = "mdl-tabs__tab is-active">Tab 1</a>
<a href = "#tab2-panel" class = "mdl-tabs__tab">Tab 2</a>
<a href = "#tab3-panel" class = "mdl-tabs__tab">Tab 3</a>
</div>
<div class = "mdl-tabs__panel is-active" id = "tab1-panel">
<p>Tab 1 Content</p>
</div>
<div class = "mdl-tabs__panel" id = "tab2-panel">
<p>Tab 2 Content</p>
</div>
<div class = "mdl-tabs__panel" id = "tab3-panel">
<p>Tab 3 Content</p>
</div>
</div>
</main>
</div>
</body>
</html>
结果
验证结果。