【发布时间】:2014-04-03 15:05:59
【问题描述】:
所以在我的网站上,我在顶部有一个固定的栏,跨越页面的长度,栏是 h1。附在上面的是一个带有返回和主页按钮的迷你导航,它位于它的下方并且也是固定的。当您向下滚动时阅读页面内容时,迷你导航会妨碍您,所以我想让导航在用户向下滚动时消失,并且还可以通过将鼠标移到顶部/单击顶部来选择让它重新出现栏/在触摸屏上滑动顶部栏等。
我该怎么做呢?
这是 HTML:
<header class="mainHeader">
<h1>Page Title</h1>
<nav class="secondaryNav">
<a href="home.htm"><img class="backButton" src="img/back2.png" alt="Back Button"></a>
<a href="home.htm"><img class="homeButton" src="img/home.png" alt="Home Button"></a>
</nav>
<aside><p id="countdown"></p></aside>
</header>
<!-- end .mainHeader -->
还有 CSS:
.mainHeader h1 {
position: fixed;
top: 0;
width: 100%;
background: #ea594e;
box-shadow: 0 0 3px 3px #888888;
font-family: verdana;
font-variant: small-caps;
color: white;
border-bottom: 1px solid black;
margin: 0;
padding-bottom: 0.5%;
text-align: center;
}
.mainHeader .secondaryNav {
background: #ffcda4;
box-shadow: 0 3px 3px 1px #888888;
border: 1px solid;
border-top: none;
width: 400px;
position: fixed;
top: 49px;
left: 50%;
margin-left: -200px;
border-radius: 0 0 50px 50px;
padding-top: 5px;
}
栏是h1,迷你导航是secondaryNav
【问题讨论】:
标签: javascript jquery html css