我有以下页面
section {
height: 1000px;
background: yellow;
margin: 50px;
}Run Code Online (Sandbox Code Playgroud)
<section id="one">Section one</section>
<section id="two">Section two</section>Run Code Online (Sandbox Code Playgroud)
如果用户来自包含哈希之后的节ID的链接,则仅使用html/css可以仅显示一个节
?
您可以调查:target伪类的使用,但是当URL哈希为空时,您可能很难显示所有部分.
例如:
section:not(:target) { display:none; }
section:target { display: block }Run Code Online (Sandbox Code Playgroud)
<a href="#one">One</a>
<a href="#two">Two</a>
<section id="one">Section one</section>
<section id="two">Section two</section>Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
55 次 |
| 最近记录: |