Using just CSS is it possible to hide/select the lowercase characters of a string?
<p>Richard Parnaby-King</p>
To show only RPK
?
Using ::first-letter
I can show only the letter R
. Is there any way to expand on this?
p {
font-size:0;
}
p::first-letter {
font-size:16px;
}
<p>Richard Parnaby-King</p>
Edit
The intent is to animate the letters out. i.e. have a css animation that starts as RPK
and expands to Richard Parnaby-King
on hover.
I am not able to alter the html.
My current thinking is to change the font colour of the p
tag to white (on white background), create an :after
element with the content "RPK" centred on the p
tag and on :hover
animate rotate the "RPK" 90 degrees then display:none
it (or something so that it is not visible), rotate the p
tag to 270 degrees and animate rotate it to finish at 360 degrees. The final effect is "RPK" rotating around and "Richard Parnaby-King" coming out of it. Below I have "sort of" the effect I have described above but it doesn't hide/show the text correctly.
p {
color: #fff;
position: relative;
text-align: center;
}
p:after {
content: "RPK";
position: absolute;
left: 0;
top: 0;
color:#000;
text-align: center;
width:100%;
}
p:hover {
animation: pSpin 1s forwards;
}
p:after:rhover {
animation: pAfterSpin 0.5s forwards;
}
@keyframes pSpin {
0% {
transform:rotateY(0deg);
color:#fff;
}
50% {
color:#000;
transform:rotateY(270deg);
}
100% {
transform:rotateY(360deg);
color:#000;
}
}
@keyframes pAfterSpin {
0% {
transform:rotateY(0deg);
color:#000;
}
100% {
transform:rotateY(90deg);
color:#fff;
z-index:-5
}
}
<p>Richard Parnaby-King</p>