[英]make header menu a fixed position(theme tesseract)
我正在尝试将tesseract主题( http://tyler.com/ )上方的标题菜单固定在一个位置 ,这样,如果您向下滚动,就可以访问网站上任何位置的所有菜单元素。
我已经尝试了几件事,并且总是添加position:fixed;
到主题的几个CSS类,但是什么也没发生。
如果您能在这个问题上帮助我,我会很高兴。 提前致谢
从position: relative
对于position: fixed
编辑此代码
.home .site-header.no-header-image {
left: auto;
position: fixed;
top: auto;
}
现在,避免隐藏最重要的内容:
.home .site-content {
padding-top: 60px;
}
产量
您可以尝试:
.<youClassName>{
position: absolute;
top: 0px;
}
这应该将菜单固定在顶部,并且将跟随您进行滚动。
除去position: relative;
加
.home .site-header.no-header-image {
position: fixed;
}
将位置固定在div上,而不是每个元素
检查这个小提琴
HTML
<div id = "menu">
<ul class = "main">
<li>
Home
</li>
<li>
About
</li>
<li>
Contact
</li>
</ul>
</div>
<div id = "content">
CONTENT CONTENT
</div>
CSS
div#menu {
position: fixed;
background-color: #0088cc;
color: #f8f8f8;
width: 100%;
height: 50px;
}
ul li {
float: left;
margin: 2%;
list-style: none;
cursor: pointer;
}
#content {
height: 1000px;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.