午前中ずっと、単純なコードだと思っていたものを書き込もうとしました。
- コンテンツの 2 つの長い列、列 1 のみが表示されます
- リンクをクリックすると、列 1 が非表示になり、列 2 が表示されます
- どちらもまったく同じ位置にありますが、長さが異なります。
疑似クラスを使用しtarget
て列を切り替え、1 つの可視性を表示するように設定することにしました。
これは機能しているように見えますが、自分が何をしたかを完全には理解していません。さらに、これらの列の下にあるコンテンツは、y 軸ではなく、z 軸でそれらの下に配置されているようです。
私の2つの(関連する)問題:
- 私が作成したもののロジックが正確にはわかりません。わかりやすい英語の説明でできます。
- 2 つの列とコンテナーの下にある DIV が y 軸でそれらの下に表示されない理由がわかりません。
これが私のCSSです:
#container
{
background-color: red;
position: relative;
}
#schools-list
{
width: 400px; /* Set the width of the visible portion of content here */
height: 600px; /* Delete the height, let the content define the height */
background-color: purple;
position: absolute;
top: 0;
left: 0;
}
#boards-list
{
width: 400px; /* Set the width of the visible portion of content here */
height: 700px; /* Delete the height, let the content define the height */
background-color: green;
position: absolute;
top: 0;
left: 0;
visibility: hidden;
}
#container:target #schools-list
{
visibility: hidden;
}
#container:target #boards-list
{
visibility: visible;
}
ここに私のHTMLがあります:
<div id="container">
<div id="boards-list">
Boards List<br>
Switch to <a href="">Schools List</a>
Here's some content
</div>
<div id="schools-list">
Schools List<br>
Switch to <a href="#container">Boards List</a>
Here's some other content
</div>
</div>
<div>Why is this beneath everything?</div>