I\'m trying to style my element with pseudo-class and pseudo-element. like hover::before
is working perfectly but :visited::before
is not working.
Mozilla Developer Network :visited says
Note: For privacy reasons, browsers strictly limit the styles you can apply using an element selected by this pseudo-class: only color, background-color, border-color, border-bottom-color, border-left-color, border-right-color, border-top-color, outline-color, column-rule-color, fill and stroke.
Idea 1: create child element and write CSS for it
Seen EffectsSeen
Seen EffectsSeen
Seen EffectsSeen
*, *:before, *:after {
box-sizing: border-box;
}
body {
background-color: #eee;
font-size: 23px;
padding: 50px;
font-family: 'Ubuntu Condensed', sans-serif;
}
.style-3 {
margin: 20px;
float: left;
padding: 20px 20px 20px 20px;
border: 1px solid #ccc;
background-color: #fff;
position: relative;
text-decoration: none;
}
.style-3 {
color: green;
}
.style-3:visited {
color: red;
}
.style-3 span{
color: #fff;
margin-left: 20px;
}
.style-3:visited span{
color: #ccc;
margin-left: 20px;
}
Fiddle https://jsfiddle.net/ZigmaEmpire/do8yeLm1/
Idea 2: create a transparent background image with text matching the background color, and change the background color for :visited (not recommended)