将绝对元素放置在彼此下方



>我正在尝试创建一个 CSS3 悬停菜单,该菜单会过渡并在其下方显示子菜单。我遇到的问题是我无法将子菜单放置在彼此下方。目前,我有这种效果 - http://jsfiddle.net/7pz3g/1/

这是 HTML 标记 -

<nav id="navbar">
    <ul class="iconContainer">
        <li>
            <a href="/"><i class="fa fa-home fa-lg"></i></a>
            <ul id="wrapperFirst" class="extMenu">
                <li><h3>Testing</h3></li>
                <li>SubMenu
                    <ul id="wrapperSecond" class="subMenu">
                        <li><h3>ORGANIZATIONS</h3></li>
                        <li><a href="http://reddit.com/‎">Reddit</a></li>
                    </ul>
                </li>
            </ul>
        </li>
    </ul>
</nav>

CSS 标记 -

li {
    list-style: none;
}
#navbar {
    background-color: #333333;
    position: fixed;
    text-align: center;
    left: 0;
    top: 0;
    height: 100%;
    z-index: 100;
    width: 60px;
    display: table;
}
#navbar .iconContainer li {
    color: white;
    padding: 0 2%;
    border-bottom: 1px solid rgba(255, 255, 255, .2);
    cursor: pointer;
    height: 60px;
}
#navbar .iconContainer li:first-child {
    border-top: 1px solid rgba(255, 255, 255, .2);    
}
#navbar i {
    text-decoration: none;
    color: white;
    line-height: 60px;
    font-size: 1.5em;
    text-shadow: 1px 1px 1px #000;
    width: 60px;
    opacity: .5;
}
#navbar .iconContainer {
    padding: 0;
    margin: 0;
    display: table-cell;
    vertical-align: middle;
    z-index: 510;
}
#navbar li:hover i {
    background-color: #222222;
    opacity: 1;
}
#navbar li:hover #wrapperFirst.extMenu {
    left: 60px;
}
#wrapperFirst.extMenu {
    background-color: #222;
    height: 100%;
    left: -1000px;
    position: fixed;
    top: 0;
    bottom: 0;
    width: 250px;
    padding: 0px;
    -webkit-transition: all 1s ease;
    -moz-transition: all 1s ease;
    -ms-transition: all 1s ease;
    -o-transition: all 1s ease;
    transition: all 1s ease;
}
#wrapperFirst.extMenu .raq {
    text-align: right;
    float: right;
    color: #75A4C7;
}
#wrapperFirst.extMenu li:hover #wrapperSecond.subMenu {
    left: 311px;
}
#wrapperFirst.extMenu li {
    padding: 10px 20px;
    text-align: left;
    height: auto;
    text-decoration: none;
    line-height: 40px;
    font-size: 1em;
    text-shadow: 1px 1px 1px #000;
    color: white;
    opacity: 1;
    border-bottom: 1px solid rgba(255, 255, 255, .2);
    cursor: pointer;
}
#wrapperFirst.extMenu li:first-child {
    border-top: 1px solid rgba(255, 255, 255, .2);
}
#wrapperSecond.subMenu {
    display:table-cell;
    background-color: #222;
    height: 100%;
    left: -1000px;
    position: fixed;
    top: 0;
    bottom: 0;
    width: 600px;
    -webkit-transition: all 1s ease;
    -moz-transition: all 1s ease;
    -ms-transition: all 1s ease;
    -o-transition: all 1s ease;
    transition: all 1s ease;
}
#wrapperSecond.subMenu h3 {
    text-align: center;
}
#wrapperSecond.subMenu .subtitle {
    font-family: 'SourceSansProRegular';
    font-size: .6em;
}
#wrapperSecond.subMenu li a {
    text-decoration: none;
    color: #75A4C7;
    line-height: 40px;
    font-size: 1em;
    text-shadow: 1px 1px 1px #000;
}
#wrapperSecond.subMenu li {
    padding: 10px 20px;
    text-align: left;
    height: auto;
    text-decoration: none;
    line-height: 40px;
    font-size: 1em;
    text-shadow: 1px 1px 1px #000;
    color: white;
    opacity: 1;
    border-bottom: 1px solid rgba(255, 255, 255, .2);
    cursor: pointer;
}
#wrapperSecond.subMenu li {
    opacity: 1;
}
#wrapperSecond.subMenu {
    width: 600px;
    opacity: 1;
}
#wrapperSecond.subMenu h3 {
    text-align: center;
}
#wrapperSecond.subMenu .subtitle {
    font-family: 'SourceSansProRegular';
    font-size: .6em;
}
#wrapperSecond.subMenu li a {
    text-decoration: none;
    color: #75A4C7;
    line-height: 40px;
    font-size: 1em;
    text-shadow: 1px 1px 1px #000;
}

我希望每个子菜单都在其根菜单下方过渡,但仍保留在页面上的其他元素之上。有什么想法吗?谢谢!!!

http://jsfiddle.net/ypzcG/

#wrapperSecond.subMenu li {
    opacity: 1;
    position: relative;
    margin-top: 70px;
}

相关内容

  • 没有找到相关文章

最新更新