随页面滚动的 CSS 子菜单

标签 css wordpress scroll submenu

您好,我必须使用 wordpress 为网站创建水平子菜单。我还有 1 个问题,当您在页面中途滚动链接时,子菜单出现在页面的中途。我认为这是因为:

position: fixed;
        top: 264px;
        left: 50%;
        width: 1000px;
        margin-left:-500px;

有办法解决这个问题吗?

网站是:http://dev.timson.me (关于“即将上映”和“过去制作”的子菜单)

CSS 是:

#access {
clear: both;
display: block;
float: left;
margin: 0 auto 6px;
padding-top: 8px;
width: 100%;
font-family: Stag;
display:block;
text-align:center;
}

#access ul {
    font-size: 13px;
    list-style: none;
    margin: 0 0 0 -0.8125em;
    padding-left: 0;

    display:inline-block;
}

.sub-menu {
    text-align: center;
}

#menu-default > li {
    float: left;
    position: relative;
}
.sub-menu > li {
    display: inline-block;
}

#access a {
    color: #eee;
    display: block;
    line-height: 25px;
    margin-top: -4px;
    margin-bottom: -4px;
    padding: 0 1.2125em;
    text-decoration: none;
}

#access ul ul {

    display: none;
    float: left;
    margin-top: 0;
    position: fixed;
    top: 264px;
    left: 50%;
    width: 1000px;
    z-index: 99999;
    margin-left:-500px;
    text-align:center;
    padding-top:5px;
    padding-bottom:10px;

    background: red;
}

#access ul ul a {

    margin-top: 0px;
    margin-right: auto;
    margin-bottom: 0px;
    margin-left: auto;
    padding-bottom:10px;

}

#access ul li:hover > ul {
    display: block;
}

非常感谢任何帮助。

干杯, 彼得

最佳答案

去掉

position: fixed;

那应该就可以了。

关于随页面滚动的 CSS 子菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9577208/

相关文章:

css - WordPress - 在每个页面上隐藏一个元素,除了一个

javascript - 使用断点拼接调整大小函数

jquery - 系统地为每个 A 添加不同的 CSS 边框,即使它们位于子 div 中

css - 为什么我的@font-face 声明不能在 wordpress 上运行?

javascript - DIV 不像 Marquee 那样正确滚动

ios - UICollection 的镜像滚动

html - 如何使 float 文本换行而不是打断 float ?

mysql - 在 WordPress 自定义 SELECT 查询中使用 MIN

html - 指定图像宽度全尺寸 WordPress

css - 当 div 使用 css 增长时自动向下滚动父 div