CSS 不适用于 Wordpress 自定义菜单

标签 css wordpress

我正在尝试在我的 Wordpress 主题中安装自定义菜单。我已成功启用该功能并将菜单嵌入到我的布局中,唯一的问题是 CSS 不适用于菜单。

我有一个名为 NAV 的自定义 CSS,我还尝试将 21 个中的 CSS 复制并粘贴到我的 CSS 中(称为访问)。但无论我做什么,导航样式都不会改变。我开始认为这可能是我的嵌入代码。在这里:

<?php wp_nav_menu( array( 'sort_column' => 'menu_order', 'container_class' => 'access', 'menu_class' => 'access' ) ); ?>

这是生成的 HTML:

<div class="access">
<ul id="menu-home" class="access">
<li id="menu-item-10" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-10"><a href="http://www.studentbridges.org/new/sample-page/">About Us</a>
<ul class="sub-menu">
<li id="menu-item-11" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-11"><a href="http://www.studentbridges.org/new/sample-page/history/">History</a>      
</li>
</ul>
</li>
</ul>
</div>

这是相关的 CSS:

#access {
background: #222; /* Show a solid color for older browsers */
background: -moz-linear-gradient(#252525, #0a0a0a);
background: -o-linear-gradient(#252525, #0a0a0a);
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#252525), to(#0a0a0a));   /* older webkit syntax */
background: -webkit-linear-gradient(#252525, #0a0a0a);
-webkit-box-shadow: rgba(0, 0, 0, 0.4) 0px 1px 2px;
-moz-box-shadow: rgba(0, 0, 0, 0.4) 0px 1px 2px;
box-shadow: rgba(0, 0, 0, 0.4) 0px 1px 2px;
clear: both;
display: block;
float: left;
margin: 0 auto 6px;
width: 100%;
}
#access ul {
font-size: 13px;
list-style: none;
margin: 0 0 0 -0.8125em;
padding-left: 0;
}
#access li {
float: left;
position: relative;
}
#access a {
color: #eee;
display: block;
line-height: 3.333em;
padding: 0 1.2125em;
text-decoration: none;
}
#access ul ul {
-moz-box-shadow: 0 3px 3px rgba(0,0,0,0.2);
-webkit-box-shadow: 0 3px 3px rgba(0,0,0,0.2);
box-shadow: 0 3px 3px rgba(0,0,0,0.2);
display: none;
float: left;
margin: 0;
position: absolute;
top: 3.333em;
left: 0;
width: 188px;
z-index: 99999;
}
#access ul ul ul {
left: 100%;
top: 0;
}
#access ul ul a {
background: #f9f9f9;
border-bottom: 1px dotted #ddd;
color: #444;
font-size: 13px;
font-weight: normal;
height: auto;
line-height: 1.4em;
padding: 10px 10px;
width: 168px;
}
#access li:hover > a,
#access ul ul :hover > a,
#access a:focus {
background: #efefef;
}
#access li:hover > a,
#access a:focus {
background: #f9f9f9; /* Show a solid color for older browsers */
background: -moz-linear-gradient(#f9f9f9, #e5e5e5);
background: -o-linear-gradient(#f9f9f9, #e5e5e5);
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#f9f9f9), to(#e5e5e5)); /* Older webkit syntax */
background: -webkit-linear-gradient(#f9f9f9, #e5e5e5);
color: #373737;
}
#access ul li:hover > ul {
display: block;
}
#access .current-menu-item > a,
#access .current-menu-ancestor > a,
#access .current_page_item > a,
#access .current_page_ancestor > a {
font-weight: bold;
}

#img {border-bottom:2px solid #9bc5c4;margin:0;padding:0;max-height:125px;overflow:hidden;} #block-cck_blocks-field_hdr_img {height:128px;overflow:hidden;}
#nav {height:45px;background:url(img/main-nav-bkgd.jpg) repeat-x     #26243c;width:1008px;height:45px;z-index:90;position:relative;}
#nav ul.nice-menu {width:993px;margin:0 0 0 15px;padding:0;display:inline;}
#nav ul.nice-menu li {display:block;float:left;background:none;border:none;position:relative;color:#FFF;font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;height:45px;font-size:13px;font-weight:bold;}
#nav ul.nice-menu li a {display:block;color:#FFF;font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;padding:13px 23px 14px 23px;font-size:13px;font-weight:bold;text-decoration:none;}
#nav ul.nice-menu li a:hover, #nav ul.nice-menu-down li.menuparent:hover a, #nav ul.nice-menu-down li.over a, #nav ul li.active-trail a {background:url(img/nav-over.jpg) repeat-x;}
#nav ul.nice-menu li ul {position:absolute;top:45px;left:0;}
#nav ul.nice-menu li ul li {width:200px;margin:0;padding:0;height:auto!important;}
#nav ul.nice-menu li ul li a, #nav ul.nice-menu-down li.menuparent ul li a {font-size:11px;color:#231f20;font-family:Georgia, "Times New Roman", Times, serif;display:block;clear:both;padding:5px 20px;margin:0;width:160px;background:#dfccb0!important;border-bottom:1px solid #FFF;font-weight:normal;}
#nav ul.nice-menu li ul li a:hover, #nav ul.nice-menu-down li.menuparent ul li a:hover {background:#d0b389!important;}
#nav ul.nice-menu li ul li ul {display:none;}

关于我可能做错了什么的任何意见???

最佳答案

您的导航包装器有一个 class “活跃”但在你的CSS中你的目标是ID .

选项 1

更改 #access.access

选项 2(这可能更容易)

更改<div class="access"><div id="access">

Working example

关于CSS 不适用于 Wordpress 自定义菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11766281/

相关文章:

javascript - 将站点导航 HTML 导入所有页面的最简单方法是什么?

html - 部分元素不调整/保持格式以适应不同的屏幕尺寸?

mysql - 查询更新MYSQL数据库中的数据,在表1中查找,在表2中更新,如何实现?

php - jquery Accordion 选项卡

wordpress - wp_editor api 未在自定义用户配置文件字段中写入 p 标签

javascript - addCssFile() 在我们的应用程序中不再起作用。未被调用且不执行任何操作

javascript - 导出为 .txt 并排显示所有 <p> 行,而不是逐行显示 javascript jquery

jquery - 使用 CSS 的导航栏高度过渡

php - 为什么 substr(...) 没有做我想要它做的事?

wordpress - 用于运费计算器的 Woocommerce 自定义字段