【发布时间】:2018-04-04 11:01:34
【问题描述】:
我查看了几乎所有相关的问题,并尝试使用 ui-router 的 ui-sref 功能更改导航链接的字体颜色。但是,我没有看到字体颜色的变化,但是当我将其添加到 CSS 中的 .active 类时,我确实看到了背景颜色的变化。 如果有人能指出以下内容有什么问题,我将不胜感激。我只想在路由处于活动状态时更改字体颜色。即
<nav>
<ul>
<li ui-sref-active="active" ng-class="{active: activeListItem == 'home'}"> <a ui-sref="Home "><img src="images/icon-information.png"> Introduction </a> </li>
<li ui-sref-active="active" ng-class="{active: activeListItem == 'testInfo'}"> <a ui-sref ="TestInfo"> <img src="images/icon-settings.png"> SmartCart Setup</a></li>
<li ui-sref-active="active" ng-class="{active: activeListItem =='errorScenarios'}" > <a ui-sref="ErrorScenarios"><img src="images/icon-error.png"> Error Scenarios </a> </li>
<li ui-sref-active="active" ng-class="{active: activeListItem == 'contactUs'}" > <a ui-sref="ContactUs"><img src="images/icon-contact.png"> Contact </a> </li>
</ul>
</nav>
我的 css 有以下
body {
font-family: 'Encode Sans', sans-serif;
font-weight: 400;
margin-top: 0px;
}
a {
color: #F04a24;
text-decoration: none;
font-weight: 600;
border-bottom: 2px dotted #F04a24;
}
a:hover {
color: #512b83;
border-bottom: 2px dotted #512b83;
}
h1 {
color: black;
font-family: 'Encode Sans', sans-serif;
font-weight: 300;
font-size: 3em;
}
h2 {
color: #512b83;
font-family: 'Encode Sans', sans-serif;
font-size: 1.75em;
font-weight: 800;
text-transform: uppercase;
}
h3 {
color: #512b83;
font-family: 'Encode Sans', sans-serif;
font-size: 1.25em;
font-weight: 800;
text-transform: uppercase;
}
.panel-heading h3, .panel-heading h4 {
color: #512b83;
font-family: 'Encode Sans', sans-serif;
font-weight: 800;
text-transform: uppercase;
}
nav {
font-size: 1em;
}
nav a {
border-bottom: none;
font-size: 1em;
font-weight: 400;
color: #512b83;
}
nav a:hover {
border-bottom: none;
color: #512b83;
font-size: 1em;
font-weight: 600;
}
nav li img{
width: 20px;
}
.active
{
color:red;
}
【问题讨论】:
-
请同时展示您的 JS 或创建一个 plunker/fiddle。
标签: html css angularjs angular-ui-router