テキストの選択
ユーザーがコンテンツを操作するときの選択方法を変えます。
This paragraph will be entirely selected when clicked by the user.
This paragraph has default select behavior.
This paragraph will not be selectable when clicked by the user.
<p class="user-select-all">This paragraph will be entirely selected when clicked by the user.</p>
<p class="user-select-auto">This paragraph has default select behavior.</p>
<p class="user-select-none">This paragraph will not be selectable when clicked by the user.</p>ポインターイベント
Bootstrapは、要素の相互作用を防止したり、追加したりするための.pe-noneと.pe-autoクラスを提供しています。
This link can not be clicked.
This link can be clicked (this is default behavior).
This link can not be clicked because the pointer-events property is inherited from its parent. However, this link has a pe-auto class and can be clicked.
<p><a href="#" class="pe-none" tabindex="-1" aria-disabled="true">This link</a> can not be clicked.</p>
<p><a href="#" class="pe-auto">This link</a> can be clicked (this is default behavior).</p>
<p class="pe-none"><a href="#" tabindex="-1" aria-disabled="true">This link</a> can not be clicked because the <code>pointer-events</code> property is inherited from its parent. However, <a href="#" class="pe-auto">this link</a> has a <code>pe-auto</code> class and can be clicked.</p>.pe-noneクラス(およびそれが設定するpointer-eventsCSSプロパティ)は、ポインタ(マウス、スタイラス、タッチ)による相互作用を防ぐだけです。.pe-noneが設定されたリンクやコントロールは、デフォルトではキーボードユーザーでもフォーカスやアクションが可能です。キーボードユーザーに対しても完全に無効化するためには、tabindex="-1"(キーボード・フォーカスを受け取らないようにする)、aria-disabled="true"(事実上無効化されていることを支援技術に伝える)などの属性を追加し、場合によっては JavaScript を使用してアクション可能であることを完全に防ぐ必要があるかもしれません。
可能であれば、より簡単な解決策もあります:
- フォームコントロールの場合、
disabled属性を追加します。 - リンクの場合は
href属性を削除し、非インタラクティブなアンカーリンクまたはプレースホルダーリンクにします。
CSS
SassユーティリティAPI
インタラクションユーティリティは、ユーティリティAPIのscss/_utilities.scssで宣言されています。ユーティリティAPIの使い方はこちら
"user-select": (
property: user-select,
values: all auto none
),
"pointer-events": (
property: pointer-events,
class: pe,
values: none auto,
),