プラグイン不要で複数設置可能なモーダルウィンドウの実装方法をご紹介します。
【実装のポイント】
- ボタンとモーダルコンテンツをidで紐づけて複数対応を可能にしています。
- モーダルを開いた後どこをクリックしても閉じるようにしています。
CSSやhtmlの構造はお好みで調整ください。
【最低限のサンプル】
See the Pen easy modal by H M (@abiwvsjx-the-builder) on CodePen.
【ちょっと整えたサンプル】
See the Pen easy modal deco by H M (@abiwvsjx-the-builder) on CodePen.