- 物化教程
- 物化 - 主页
- 实现 - 概述
- Materialise - 环境设置
- 物化 - 颜色
- 物化 - 网格
- Materialise - 帮助者
- 物化 - 媒体
- 物化 - 阴影
- Materialize - 表格
- 物化 - 版式
- 物化 - 徽章
- Materialize - 按钮
- 物化 - 面包屑导航
- 物化 - 卡片
- Materialise - 芯片
- Materialize - 集合
- 物化 - 页脚
- 物化-形式
- 物化 - 图标
- Materialize - 导航栏
- Materialize - 分页
- Materialise - 预加载器
- Materialize - 可折叠
- Materialize - 对话框
- Materialize - 下拉菜单
- Materialise - 选项卡
- 物化 - 波浪
- 物化有用的资源
- Materialise - 快速指南
- Materialise - 有用的资源
- 实现 - 讨论
Materialize - 对话框
Materialise 提供了各种特殊方法来向用户显示不引人注目的警报。Materialise 为他们提供了一个术语 toast。以下是将对话框显示为 toast 的语法。
Materialize.toast(message, displayLength, className, completeCallback);
在哪里,
- message - 要显示给用户的消息。
- displayLength - 消息消失的持续时间。
- className - 应用于 toast 的样式类。例如,“圆形”。
- CompleteCallback - Toast 关闭后调用的回调方法。
对于工具提示,Materialize 提供了以下 CSS 类。
| 先生。 | 类名和描述 |
|---|---|
| 1 | 工具提示的 标识具有工具提示的组件。 |
| 2 | 数据位置 工具提示的位置;底部、顶部、左侧或右侧。 |
| 3 | 数据延迟 设置工具提示的持续时间,之后它将消失。 |
| 4 | 数据工具提示 设置工具提示内容。 |
例子
以下示例演示了 toast 和工具提示的使用。
<html>
<head>
<title>The Materialize Dialogs Example</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.3/css/materialize.min.css">
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.3/js/materialize.min.js"></script>
<script>
function showToast(message, duration){
Materialize.toast(message, duration);
}
function showToast1(message, duration){
Materialize.toast('<i>'+ message + '</i>', duration);
}
function showToast2(message, duration){
Materialize.toast(message, duration, 'rounded');
}
function showToast3(message, duration){
Materialize.toast('Hello World!', duration, '', function toastCompleted(){
alert('Toast dismissed!');
});
}
</script>
</head>
<body class="container">
<h4>Toasts</h4>
<a class="btn" onclick="showToast('Hello World!', 3000)">Normal Alert!</a>
<a class="btn" onclick="showToast1('Hello World!', 3000)">Italic Alert!</a>
<a class="btn" onclick="showToast2('Hello World!', 3000)">Rounded Alert!</a>
<br/><br/>
<a class="btn" onclick="showToast3('Hello World!', 3000)">Callback Alert!</a>
<h4>Tooltips</h4>
<a class="btn tooltipped" data-position="bottom" data-delay="50" data-tooltip="I am in bottom!">Bottom</a>
<a class="btn tooltipped" data-position="left" data-delay="50" data-tooltip="I am in left!">Left</a>
<a class="btn tooltipped" data-position="right" data-delay="50" data-tooltip="I am in right!">Right</a>
<a class="btn tooltipped" data-position="top" data-delay="50" data-tooltip="I am in top!">Top</a>
</body>
</html>
输出
验证输出。
