<a>
<svg id="highlighter">
<clipPath id="myClip">
<rect id="clipRect" x="0" y="0" width="100%" height="100%" />
</clipPath>
<filter id="displacementFilter1">
<feTurbulence type="turbulence" baseFrequency="0.0125" numOctaves="2" result="turbulence" />
<feDisplacementMap in2="turbulence" in="SourceGraphic" scale="4" xChannelSelector="R" yChannelSelector="G" />
</filter>
<g clip-path="url(#myClip)">
<rect id="highlightRect1" x="0" y="0" width="96%" height="90%" fill="#ffc2d4" style="filter: url(#displacementFilter1)"> </rect>
</g>
</svg>
Hover to highlight! 🎨
</a>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
display: grid;
place-items: center;
height: 100vh;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
line-height: 1;
color: #111;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
a {
position: relative;
letter-spacing: -0.0125em;
font-weight: 600;
font-size: 2.25rem;
cursor: pointer;
text-align: center;
white-space: nowrap;
text-overflow: ellipsis;
}
#highlighter {
position: absolute;
top: -4px;
left: -4px;
width: calc(100% + 18px);
height: calc(100% + 12px);
overflow: visible;
z-index: -1;
transform: translate3d(0px, 0px, 0px);
}
#highlighter > * {
pointer-events: none;
}
a:hover #clipRect {
transform-origin: 0 0;
transform: scaleX(1);
}
#clipRect {
transform-origin: 100% 50%;
transform: scaleX(0);
transition: transform 275ms ease;
}
@media only screen and (max-width: 768px) {
a {
font-size: 1.875rem;
}
}
This Pen doesn't use any external CSS resources.