css - 当前页面导航颜色不同

标签 css

我认为标题没有很好地解释我的问题。基本上,在我的导航栏上,我希望当前页面是不同的颜色。

例如,如果所有的导航链接都是黑色的,我希望主页的当前页面是红色的。我试过给当前页面链接一个类,然后给它定义一种颜色,但它似乎没有改变。

这是我的代码: http://jsfiddle.net/SCd4h/

    <style>
.box {
text-align: center;
background-color: #F1F2F2;
border: 1.5px #D1D3D4 solid;
border-bottom: 3px solid red;
    margin: 5px;
    padding: 10px;
}
p {
font-size: 15px;
font-family: arial;
color: #585858;
}
.logo {
margin-left:70px;
margin-top: -160px;
}
a:visited {
  text-decoration: none;
  color: black;
  font-weight: normal;
}
a:link {
  text-decoration: none;
  color: black;
  letter-spacing: 500;
}
a:hover {
  text-decoration: none;
  color: #FC3B3B;
  background: white;
}
a:active {
  text-decoration: none;
  color: red;
  font-weight: normal;
}

ul {
list-style-type:none;
margin-right:50px;
margin-top: 60px;
padding:5px;
overflow: hidden;
font-family: 'Paytone One', sans-serif;
font-size: 18px;
}
li {
display:inline;
float:right;
margin-right: 30px;
}
.current {
font-family: 'Paytone One', sans-serif;
font-size: 18px;
color:red;
}
</style>

<body>
<ul>
<li><a href="index.html"/>HOME</a></li>
<li><a href="blog.html"/>BLOG</a></li>
<li><a href="photo.html" class="current"/>PHOTOS</a><li>
<li><a href="projects.html"/>PROJECTS</a></li>
</ul>

</br>
<img class="logo" src="louis2.png" alt="." width="149px" height="150px"/>
<div class="box">

</div>
<div class="box1">
</div>
<p>louismoore.net © All rights reserved 2012</p>
</body>

最佳答案

您的问题是 specificity .

尝试

a.current相反。

此外,删除 /从你的开头 A 标签里面。应结构<a>...</a>

关于css - 当前页面导航颜色不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14074107/

相关文章:

javascript - 激活滚动功能

javascript - 如何使轮播和滚动动画在单个网页上协同工作

javascript - 使 polymer 纸标签居中

html - hr标签的自定义CSS

php - 动态PHP网页保存为PDF

css - 使用表格作为表格是否可以接受?还是使用 div 更正确?

css - ionic 应用程序中的 Sass 错误 "isn' t 一个有效的 CSS 值

jquery - 将 jQuery nestedSortable 元素(正在拖动)限制在容器内?

html - 按钮和文字不在一条线上

html - div 垂直 float