make header menu a fixed position(theme tesseract)

2019-09-05 14:38发布

I am trying to make the header menu ontop of the tesseract theme (http://tyler.com/ ) a fixed position, so that if you scroll down one can access all menu elements from any postion on the site.

I have tried a few things and always added position:fixed; to a few css classes of the theme, but nothing happened.

I would be glad, if you could help me out with this issue. Thanks in advance

4条回答
放荡不羁爱自由
2楼-- · 2019-09-05 15:03

You could try:

.<youClassName>{
    position: absolute;
    top: 0px;
}

This should fix your menu to the top and it will follow you on scrolling.

查看更多
虎瘦雄心在
3楼-- · 2019-09-05 15:07

Edit this code from position: relative to position: fixed

.home .site-header.no-header-image {
  left: auto;
  position: fixed;
  top: auto;
}

Now to avoid the top content getting hidden:

.home .site-content {
  padding-top: 60px;
}

Output Output

查看更多
萌系小妹纸
4楼-- · 2019-09-05 15:07

remove position: relative;

add

.home .site-header.no-header-image {
  position: fixed;
}

enter image description here

查看更多
乱世女痞
5楼-- · 2019-09-05 15:29

Add position fixed to a div not in every element

check this fiddle

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;
}
查看更多
登录 后发表回答