我有一个风格,用于设置导航栏上的链接,但它会设置网站中所有其他链接的样式,因此我将div“menubar”定义为链接和访问选择器前面的选择器,但它仍然样式全部网站中的链接。任何解决方案将不胜感激。
CSS:
#menubar a:link, a:visited
{
border-top-width: 1px;
display: block;
font-weight: bold;
color: #000000;
background-color: #EFF1EB;
width: 180px;
text-align: center;
padding: 4px;
text-decoration: none;
text-transform: uppercase;
border-style: solid;
border-color: #638529;
font-family: Arial, Helvetica, sans-serif;
border: 1px;
position: fixed;
}
答案 0 :(得分:2)
你的选择器错了,改为这个:
#menubar a:link, #menubar a:visited /* width #menubar after the comma */
您的初始选择器#menubar a:link, a:visited
表示:“#menubar中的所有链接以及整个文档中的所有访问过的链接”。逗号启动一个全新的选择器,因此您必须将父级也包含在第二个选择器中。
答案 1 :(得分:1)
我认为@Yotam是对的。
另一个想法如何调试这个。我在Firefox中使用Web开发工具栏。它有很多工具,一个是检查页面。使用一个来查看样式(我喜欢3D视图),在那里你可以按下html元素,在你的情况下链接。在页面旁边,它列出了样式表定义。订单显示了活动样式。 Top处于活动状态,而其他的则更低并被覆盖。
在这种情况下,您可能会看到,如果您的按钮具有您想要的正确定义。