css - 居中 block 菜单 `<li>` 元素在 `<div>`

标签 css wordpress menu centering

这应该很简单 - 我确信我只是遗漏了一些简单的东西。

我有一个标题,想要一个嵌套的、居中的水平菜单。

#header {
    background:url(images/headers/header.gif);
    margin: 0 auto;
    height: 207px;
    width: 100%;
}

/* =Menu
-------------------------------------------------------------- */

#access {
    background: transparent;
    display: block;
    text-align: center;
    float: left;
    margin: 150px auto 0;
    width: 940px;
}
#access .menu-header,
div.menu {
    font-size: 13px;
    margin-left: 120px;
    width: 766px;
}
#access .menu-header ul,
div.menu ul {
    list-style: none;
    margin: 0 auto;
}
#access .menu-header li,
div.menu li {
    background-color: #444;
    margin: 0 auto;
    float: left;
    text-align: center;
    width: 110px;
    position: relative;
}
#access a {
    color: #aaa;
    display: block;
    line-height: 38px;
    padding: 0 10px;
    text-decoration: none;
}
#access ul ul {
    box-shadow: 0px 3px 3px rgba(0,0,0,0.2);
    -moz-box-shadow: 0px 3px 3px rgba(0,0,0,0.2);
    -webkit-box-shadow: 0px 3px 3px rgba(0,0,0,0.2);
    display: none;
    position: absolute;
    top: 38px;
    left: 0;
    float: left;
    width: 180px;
    z-index: 99999;
}
#access ul ul li {
    min-width: 180px;
}
#access ul ul ul {
    left: 100%;
    top: 0;
}
#access ul ul a {
    background: #333;
    line-height: 1em;
    padding: 10px;
    width: 160px;
    height: auto;
}
#access li:hover > a,
#access ul ul :hover > a {
    background: #444;
    color: #fff;
}
#access ul li:hover > ul {
    display: block;
}
#access ul li.current_page_item > a,
#access ul li.current-menu-ancestor > a,
#access ul li.current-menu-item > a,
#access ul li.current-menu-parent > a {
    color: #fff;
}
* html #access ul li.current_page_item a,
* html #access ul li.current-menu-ancestor a,
* html #access ul li.current-menu-item a,
* html #access ul li.current-menu-parent a,
* html #access ul li a:hover {
    color: #fff;
}

网站:http://74.86.183.200/~riaharb/stage/

提前致谢!

最佳答案

这不是非常棘手的,这应该可行:

#parent_ul {
width: 80%;
text-align: center;
margin: 0 auto;
}

#parent_ul > li {
display: inline; /* or inline-block */
}

关于css - 居中 block 菜单 `<li>` 元素在 `<div>`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3856682/

相关文章:

vb.net - 如何阻止我的工具条菜单项出现在任务栏中?

android - 显示操作栏菜单按钮

css - 如何将我的 div float 在我的内容的最底部

php - Woocommerce API 回调不接受 POST 参数

html - 如何将此菜单栏向右移动

WordPress 网站速度慢得令人痛苦

javascript - 放大 iframe 中的图像不适用于 IE 和 Google Chrome

html - 如何在css中改变TEXT的背景颜色

php - 如何使用 MySQL 手动跟踪 Wordpress 中的沙箱 Paypal 重复交易