Materialize教程

Materialize 对话框

Materialize 提供了各种特殊方法来向用户显示不显眼的警报。 Materialise 为他们提供了一个术语 toast。以下是将对话框显示为吐司的语法。
Materialize.toast(message, displayLength, className, completeCallback);
哪里,
message-显示给用户的消息。 displayLength-消息消失后​​的持续时间。 className-应用于 toast 的样式类。例如,"四舍五入"。 completeCallback-取消 toast 后要调用的回调方法。
对于工具提示,Materialize 提供了以下 CSS 类。
Sr.No. 类名和描述
1
tooltipped
标识具有工具提示的组件。
2
data-position
工具提示的位置;底部、顶部、左侧或右侧。
3
data-delay
设置工具提示消失的持续时间。
4
data-tooltip
设置工具提示内容。

示例

以下示例演示了 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>

输出

验证输出。
Materialize Dialogs
昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4