【问题标题】:Dropdown menu doesn't appear Foundation 5Foundation 5 没有出现下拉菜单
【发布时间】:2014-05-11 16:10:49
【问题描述】:

我一直在使用 Foundation 制作下拉菜单,但我的菜单没有出现。每次我将鼠标悬停在父链接上时,下拉菜单仅在我将鼠标悬停在菜单应该位于的区域后才会出现。有什么想法吗?

JS 小提琴:http://jsfiddle.net/hHP4q/

HTML:

<nav class="top-bar" data-topbar id="nav-bar">
        <ul class="left">
            <li class="nodrop"><a href="#">home</a></li>

        <li class="has-dropdown">
            <a href="#">SAT I</a>

            <ul class="dropdown">
                <li class="drop"><a href="#">Score a Test</a></li>

                <li class="drop"><a href="#">Past Tests</a></li>
            </ul>
        </li>

        <li><a href="#">SAT II</a></li>
    </ul>
</nav>

CSS:

.top-bar {
    width: 768px;
    margin: 0 auto;
    padding: 0;
    height: 50px;
    background-color: #518c52;
}

/* line 42, ../scss/styles.scss */
.top-bar ul {
    line-height: 50px;
    height: 50px;
}

/* line 45, ../scss/styles.scss */
.top-bar ul li {
    display: inline-block;
    float: left;
    width: 75px;
    transition: background-color 1s;
    -webkit-transition: background-color 1s;
    text-align: center;
    height: 50px;
}

/* line 53, ../scss/styles.scss */
.top-bar ul li a {
    font-size: 18px;
    color: #FFF;
}

/* line 58, ../scss/styles.scss */
.top-bar ul li:hover {
    height: 50px;
    background-color: #3e713f;
}

/* line 62, ../scss/styles.scss */
.top-bar ul .dropdown {
    width: 100px;
    margin: 0;
    padding: 0;
}

/* line 67, ../scss/styles.scss */
.top-bar ul .drop {
    width: 100px;
    margin: 0;
    padding: 0;
}

【问题讨论】:

  • 包括Foundation topbar js..它在文档中给出..
  • @Lakshay,我已经包含在foundation.min.js中,默认所有的js文件都有

标签: html css drop-down-menu zurb-foundation


【解决方案1】:

DEMO

我所做的是将 ul 隐藏在 .dropdown 类 li 中并在悬停时显示它。

CSS:

.top-bar {
    width: 768px;
    margin: 0 auto;
    padding: 0;
    height: 50px;
    background-color: #518c52;
}
/* line 42, ../scss/styles.scss */
 .top-bar ul {
    line-height: 50px;
    height: 50px;
}
/* line 45, ../scss/styles.scss */
 .top-bar ul li {
    display: inline-block;
    float: left;
    width: 75px;
    transition: background-color 1s;
    -webkit-transition: background-color 1s;
    text-align: center;
    height: 50px;
    background-color: #518c52;
}
.top-bar ul li.has-dropdown ul {
    display:none;
}
.top-bar ul li.has-dropdown:hover ul {
    display:block;
}
/* line 53, ../scss/styles.scss */
 .top-bar ul li a {
    font-size: 18px;
    color: #FFF;
}
/* line 58, ../scss/styles.scss */
 .top-bar ul li:hover {
    height: 50px;
    background-color: #3e713f;
}
/* line 62, ../scss/styles.scss */
 .top-bar ul .dropdown {
    width: 100px;
    margin: 0;
    padding: 0;
}
/* line 67, ../scss/styles.scss */
 .top-bar ul .drop {
    width: 100px;
    margin: 0;
    padding: 0;
}

【讨论】:

    猜你喜欢
    • 2015-03-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多