実現したいこと
画面をスクロールした際に、position:stickyを使用し、
要素をすべてスクロールした後固定。
次の要素が重なるようにスクロールしたい。
前提
・HTML+CSS
・VisualStudio
発生している問題・エラーメッセージ
スクロールすると最初の要素の中身が切れてしまい、すべて表示させてから要素を被せることができません。
該当のソースコード
<!DOCTYPE html> <html lang="ja"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width,initial-scale=1"> <title>テスト</title> </head> <style> .company__contents{ width: 80%; } .company__contents__wrap { background-color: #FFF; border-radius: 1rem; padding: 0 3rem; } .company__table { width: 95%; padding: 0 2rem; border-collapse: collapse; margin: 0 auto; } .company__table tr { border-bottom: 2px solid #E2E8F2; } .company__table tr:last-child { border-bottom: none; } .company__table td,th { padding: 2.7rem 0 2.7rem 5rem; } .company__table th { color: #777777; font-size: 16px; font-weight: 400; } .company__table td { font-size: 16px; letter-spacing: .1rem; font-weight: 500; line-height: 2.6rem; color: #212E32; } .block { width: 100%; height: 100vh; display: flex; align-items: center; justify-content: center; position: -webkit-sticky; position: sticky; top: 0; } .block-one { background: #212E32; color: #fff; z-index: 100; height: 100%; } .block-two { background: #83437A; z-index: 200; } .block-three { background: #76937A; z-index: 300; } .company__contents--sub { font-weight: 400; font-size: 14px; } </style> <body> <!------------------------- 中身部分 -------------------------> <div class="block block-one"> <!-- コンテンツ部 --> <div class="company__contents"> <!-- 会社概要部 --> <section id="overview"> <div class="company__contents__wrap"> <table class="company__table"> <tbody> <!-- 社名 --> <tr> <th>社名</th> <td>株式会社テスト</td> </tr> <!-- 住所 --> <tr> <th>住所</th> <td> 〒000-0000<br> テストテストテスト </td> </tr> <!-- 設立 --> <tr> <th>設立</th> <td>9999年9月</td> </tr> <!-- 資本金 --> <tr> <th>資本金</th> <td>99,999,999円</td> </tr> <!-- 事業内容 --> <tr> <th>事業内容</th> <td> <p>テスト</p> <span class="company__contents--sub"> ・システム開発、保守<br> ・アプリケーション開発<br> </span> </td> </tr> <!-- 許認可 --> <tr> <th>許認可</th> <td> テスト<br> テスト<br> テスト </td> </tr> <!-- 取引銀行 --> <tr> <th>取引銀行</th> <td> 〇〇銀行<br> 〇〇銀行<br> 〇〇銀行 </td> </tr> <!-- テスト1 --> <tr> <th>テスト1</th> <td> テスト1 </td> </tr> </tbody> </table> </div> </section> </div> </div> <div class="block block-two"> <p>Two</p> </div> <div class="block block-three"> <p>Three</p> </div> </body>
試したこと
各要素(.company__contentsや.block-one)にheightをpx指定し高さを出しても途中で切れて次の要素がスクロールで被ってしまいました。
一部参考サイトのコードをお借りしています、よろしくお願いします。

回答1件
あなたの回答
tips
プレビュー