what is wrong with my css? active links not changing color

痞子三分冷 提交于 2019-12-09 03:54:20

问题


I cannot get my Wordpress menu active links to remain red.

I've added the CSS I think is relevant to the navigation of, but also the body, etc, in case that is impacting the issue.

Thanks for your help!

body {
    font-family: 'Helvetica Neue', sans-serif;
    font-size: 12px;
    line-height: 18px; 
    color: #000;
}



/* 
LINKS 
*/

a:link,
a:visited {
    text-decoration: none;
    color: #000;
}

a:hover {
    text-decoration: none;
    color: #ff0000 ;
}

a:active {
    color: #ff0000;
}

h2.entry-title-index a:link,
h2.entry-title-index a:active,
h2.entry-title-index a:visited {
    text-decoration: none;
    color: #ff0000;
}

h2.entry-title-index a:hover {
    text-decoration: none;
    color: #ff0000;
} 

a:active {
    color: #ff0000 !important;
}

/* 
HEADLINES
*/

h2, #navigation {   
    font-family: 'Helvetica Neue', sans-serif;
    margin: 0;
    font-size: 16subpx;
    font-style: normal;
    font-variant: normal;
    font-weight: 450;
    line-height: 18px;
}

#navigation a:hover::before {
         content: '+ ';
}

#navigation a:active::before {
         content: '+ ';
}

#navigation ul a.active {
    color: #ff0000;
    }


h2.entry-title, h2.entry-title-index, h2.comment-title {
    margin-top:14px;
    color: #ff0000;
}

h2.entry-title, h2.comment-title {
/*  margin: 0 0 9px 0; */
}

h2.entry-title-index {
    line-height: 17px !important;
/*  margin: 9px 0 0 0  !important; */
}

回答1:


Active is only used while a user is clicking on an element, it's not meant to indicate which page is active. You should add a class to the active navigation item and style that class.

source: http://css-tricks.com/almanac/selectors/a/active/




回答2:


it doesn't work like that, you need to set active class or id with serverside language or with js, then you can indicate active page.



来源:https://stackoverflow.com/questions/28548513/what-is-wrong-with-my-css-active-links-not-changing-color

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!