【问题标题】:Wordpress footer menu floating with height of footerWordpress 页脚菜单随页脚高度浮动
【发布时间】:2015-04-03 16:27:55
【问题描述】:

我正在构建一个 wordpress 主题,但卡在页脚菜单上。

我想像这张图片一样显示菜单。

菜单项包含子菜单项,所以 html 是这样的:

<ul>
    <li>
        Menu item 1
        <ul id="submenu">
            <li>
            sub menu item 1
            </li>

            <li>
            sub menu item etc
            </li>
        </ul>
    </li>

    <li>
        Menu item 2
        <ul id="submenu">
            <li>
            sub menu item 1
            </li>

            <li>
            sub menu item etc
            </li>
        </ul>
    </li>
</ul>

当然,像这样它会将它垂直放置在彼此之上,浮动 li 将所有主菜单项彼此相邻。

但是我必须按照设计做的是,当div高度用完时,主菜单项到达下一列。

它必须是动态的,否则我会使用 CSS 选择器。

可能有 javascript/jquery 的东西?

谢谢。

我认为这无关紧要,但这是我目前使用的 CSS,它只是将项目向左浮动

.sub-menu .menu-item {
    margin-top: 0!important;
    clear: both;
    margin-right: 0; 
}
#lastfooter ul {
    padding-top: 8px;
}

#lastfooter ul li {
    float: left;
    margin-right: 15px;
}

#lastfooter ul li a{
    color: #000;
    text-decoration: none;
}

#lastfooter ul li a:hover{
    color: #e74d25;
}

【问题讨论】:

  • 你已经做了什么?显示您的CSS
  • 我将添加 CSS,但它与此无关,因为 CSS 现在只是将项目向左浮动
  • 相关。只需在小提琴中展示它,以便我们可以做出一些事情并帮助您。 Geloof我:)

标签: html css wordpress


【解决方案1】:

您没有明确定义您希望菜单如何工作......

1 2 3
4 5 6

1 3 5
2 4 6

也许CSS multi-column layout 是您正在寻找的(仅适用于现代浏览器

.columns{
    column-count:4;
    column-gap:2em;
}

更完整的演示在http://jsfiddle.net/gaby/Y88YZ/

【讨论】:

  • 感谢您的回复,我真的很喜欢这个答案,我将使用它。现在我只需要为旧浏览器找到解决方案,因为我工作的公司仍然支持 IE8。 PS。你摇滚!
  • @andredewaard 检查 github.com/BetleyWhitehorne/CSS3MultiColumn 的 polyfill 列
  • 我不能让它在 IE 中工作,但我让它在所有支持的浏览器中工作。在 IE8 中我使用 display: none。
【解决方案2】:

您必须使用 CSS 来管理这些。试试下面的代码:

.fl { float:left;}
#footer {
    width:100%;
    background-color:#f3f3f3;
    border-radius:5px;
    -moz-border-radius:5px;
    -o-border-radius:5px;
    -webkit-border-radius:5px;
    padding:5px;
}
#footer .footer  {
    border:dashed 2px #ccc;
    border-radius:3px;
    -moz-border-radius:3px;
    -o-border-radius:3px;
    -webkit-border-radius:3px;
    padding:5px;
}
#footer .footer ul {
    padding:0px;
    margin:0px;
    width:170px;
    margin:5px 10px 5px 10px;
}
#footer .footer ul .listing_head {
    color:#000;
    font-weight:bold;
    font-size:13px;
}
#footer .footer ul li {
    list-style:none;
    display:block;
    line-height:22px;
    font-size:12px;
}
#footer .footer ul li a {
    color:#0152ab;
    text-decoration:none;
}
#footer .footer ul .feedback {
    font-size:19px;
    font-weight:bold;
    color:#375078;
}
#footer .footer ul .feedback_form label {
    font-size:13px; 
    color:#000;
    font-family:"Lucida Sans Unicode", "Lucida Grande", sans-serif;
}
#footer .footer ul .feedback_form label span {
    color:#900;
}
#footer .footer ul .feedback_form input[type="text"], #footer .footer ul .feedback_form textarea {
    width:180px;
    border: 1px #b7b4b4 solid;
    min-height:22px;
    padding:2px;
    color:#5a5858;
    background-color:#cccccc;
}
#footer .footer ul .feedback_form input[type="submit"]{
    height:29px;
    color:#900;
    background-color:transparent;
    border:0px;
    float:right;
    padding:0px;
    font-size:17px;
    cursor:pointer;
}

http://jsfiddle.net/sushilkandola/82HHJ/

【讨论】:

  • 这不适用于我想要的,因为这使它成为一个静态菜单,而对于 wordpress,它必须是动态的,因为客户必须能够添加菜单项。
  • 您对动态菜单的理解是什么?我的意思是,它实际上是你想要的,但你必须进一步设计它。
  • @andredewaard 你必须以同样的方式应用 CSS。当您从 word-press 添加菜单时,您必须在 PHP 中创建逻辑,例如父链接和子链接/
  • 这实际上不是我想要的,因为他的代码有一个左浮动的 div。 wordpress 的菜单只是我在问题中显示的一系列 ul 和 li。
猜你喜欢
  • 2013-07-28
  • 1970-01-01
  • 1970-01-01
  • 2019-07-26
  • 1970-01-01
  • 2016-01-04
  • 1970-01-01
  • 2018-02-05
相关资源
最近更新 更多