【发布时间】:2014-08-05 09:31:09
【问题描述】:
我的导航栏出现问题,并且已经卡在这个问题上几个小时了。 我的导航栏如下所示:
<div id="pages">
<?php wp_nav_menu();?>
</div>
非常简单的 wordpress 导航栏。 Wordpress 自动为该菜单上的每个页面提供一个类名,例如 .page-item-30 ,同时 wordpress 也为它们提供了所有类 .page-item。
我想要实现的是,当我将鼠标悬停在 1 页时,背景变为红色(#ff0000),字体颜色变为白色;我的 CSS 看起来像这样
#pages li{
display: inline;
float: left;
height: 20px;
padding: 5px;
margin: 0px;
margin-top: -17px;
transition: all 0.2s ease-in-out;
}
#pages li:hover{
background-color: #ff0000;
}
/**
.page-item-27:hover a{
color: white;
transition: all 0.2s ease-in-out;
}
.page-item-2:hover a{
color: white;
transition: all 0.2s ease-in-out;
}
.page-item-21:hover a {
color: white;
transition: all 0.2s ease-in-out;
}
**/
.page-item:hover a {
color: white;
transition: all 0.2s ease-in-out;
}
.current_page_item {
background-color: #ff0000;
}
.current_page_item a{
color: white;
}
现在我尝试使用 .page-item-27 左右定义字体颜色何时必须更改,但这非常不可靠,因为它依赖于页面的正确 ID。因此,如果我有一个 ID 不在我的 CSS 中的新页面,我的导航将无法正常工作。
有没有办法改变字体的颜色?
在我当前的 css 中有这个
.page-item:hover a {
color: white;
transition: all 0.2s ease-in-out;
}
在我看来应该可行,但它没有。
如果您在danielps1.de 下不完全理解,可以查看我的实时页面。只需将我的导航悬停在左侧
感谢您的帮助
【问题讨论】:
-
如果你想链接到一个演示(这非常有用),请链接到一个演示站点,例如JS Fiddle,或者类似的,否则一旦你纠正了你的问题,链接就会显示问题,不再显示问题。另外,您能否显示您想要设置样式的相关 HTML,这让我们更清楚问题。
-
以后会做,但是将wordpress集成到jsFiddle中非常复杂,如果我不能使用wordpress功能,我会错过很多内容,这是有问题的。跨度>
-
浏览器看到的 HTML 也是如此,否则你的 css 不经过预处理就无法工作。
标签: css wordpress colors hyperlink navbar