【问题标题】:CSS Submenu Scrolling with PageCSS子菜单随页面滚动
【发布时间】:2012-03-06 13:00:15
【问题描述】:

您好,我必须使用 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;
}

非常感谢任何帮助。

干杯, 彼得

【问题讨论】:

    标签: css wordpress scroll submenu


    【解决方案1】:

    摆脱

    position: fixed;
    

    应该这样做。

    【讨论】:

    • 嗯。不为我修复它(FF 10.0.2)。
    【解决方案2】:

    我认为你可以清理大量的 CSS,最终修复你的问题。

    //Remove left margin
    #access div {
        position: relative;
        width: 1000px;
    }
    
    ul, ol {
        margin: 0;
    }
    
    //Remove left margin
    #access ul {
        display: inline-block;
        font-size: 13px;
        list-style: none outside none;
        padding-left: 0;
    

    }

    //remove position relative, it is now located in the access div container. 
    #menu-default > li {
        float:left
    }
    
    #access ul ul {
        background: none repeat scroll 0 0 red;
        display: none;
        left: 0;
        margin-top: 0;
        padding-bottom: 10px;
        padding-top: 5px;
        position: absolute;
        text-align: center;
        top: 23px;
        width: 1000px;
        z-index: 99999;
    }
    

    您可能需要使用子导航调整垂直填充。希望有帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-25
      • 1970-01-01
      • 1970-01-01
      • 2015-06-03
      • 1970-01-01
      • 1970-01-01
      • 2018-01-09
      • 1970-01-01
      相关资源
      最近更新 更多