レッスンに戻る

通知を作成する

重要度: 5

<div class="notification"> を与えられたコンテンツで作成する showNotification(options) 関数を作成します。通知は1.5秒後に自動的に消えます。

オプションは

// shows an element with the text "Hello" near the right-top of the window
showNotification({
  top: 10, // 10px from the top of the window (by default 0px)
  right: 10, // 10px from the right edge of the window (by default 0px)
  html: "Hello!", // the HTML of notification
  className: "welcome" // an additional class for the div (optional)
});

新しいウィンドウでデモ

CSSのポジショニングを使って、要素を指定されたtop/rightの座標に表示します。ソースドキュメントには必要なスタイルがあります。

タスクのためのサンドボックスを開きます。