I am appending a Glyphicon to an element using a pseudo element.
See this JsFiddle - hover the headline and notice the icon. I would like the icon itself to become transparent inside the white circle...to cut through the background so see the color beneath.
I can't just add certain color...I need more a flexible solution. I'm also aware of background-clip
and mix-blend-mode
mentioned here, but to my knowledge they don't seem to work on pseudo icons.
I tried with:
h1:hover::after {
background-color: #fff;
color: transparent;
}
And it does make the icon transparent, but in a way so that it disappears completely.
Markup:
<h1>This is a long headline. An icon is appended automatically</h1>
CSS:
h1 {
color: #fff;
display: inline-block;
padding-right: 30px;
}
h1::after {
color: #fff;
border: 1px solid #fff;
top: -3px;
left: 8px;
border-radius: 50%;
padding: 4px 0;
display: inline-block;
width: 30px;
position: relative;
height: 30px;
text-align: center;
margin-right: -30px;
font-family: 'Glyphicons Halflings';
font-size: 18px;
font-weight: 700;
line-height: 1;
content: "e258";
}
h1:hover::after {
background-color: #fff;
color: transparent;
}
Can it be done using css only and no extra markup?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…