作成方法:分屏(1/2)
- 前のページ ポップアップチャットウィンドウ
- 次のページ お客様の評価
CSSを使用して分屏(50/50)効果を作成する方法を学びます。
分屏の作成方法
第1ステップ - HTMLを追加:
<div class="split left"> <div class="centered"> <img src="img_avatar2.png" alt="Avatar woman"> <h2>ジェーン・フレックス</h2> <p>テキストがあります。</p> </div> </div> <div class="split right"> <div class="centered"> <img src="img_avatar.png" alt="Avatar man"> <h2>ビル・ゲイツ</h2> <p>ここにもテキストがあります。</p> </div> </div>
第2ステップ - CSSを追加:
/* スクリーンを二分割する */ .split { height: 100%; width: 50%; position: fixed; z-index: 1; top: 0; overflow-x: hidden; padding-top: 20px; } /* 左側を制御 */ .left { left: 0; background-color: #111; } /* 右側を制御 */ .right { right: 0; background-color: red; } /* コンテンツを水平和垂直方向に中央に配置するため */ .centered { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center; } /* 画像を中央に配置する必要がある場合、このスタイルを設定 */ .centered img { width: 150px; border-radius: 50%; }
- 前のページ ポップアップチャットウィンドウ
- 次のページ お客様の評価