简体   繁体   中英

Unordered list of hyperlinks - Match bullet color with link text color

I have created a with all list items as hyperlinks.
What I want here is that the bullet color should match the color of the hyperlink depending on its status(visited or not visited).
I want to use only CSS. Is this possible? If I could also match the colors while hovering cursor over the link, it would be great.

Try this

li {
    color:red
}
a {
    color:red;
    display:block
}
li:hover, a:hover{
    color:green
}

DEMO

You can remove the standard bullet :

ul {
    list-style: none;
}

and re-create it in the a

a::before {
    content: "\2022";
}

now the style of the a includes the bullet

a:visited {
    color: red;
}

non desired effect: the bullet is underlined as it is now part of the a.

I think that could be overdone with more work, anyway.

demo in jsfiddle

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM