This code creates a visually engaging "Text Refraction Effect," making text appear as though it is submerged and distorted beneath moving water. It combines structural HTML, CSS styling, and keyframe animations to simulate a watery environment complete with shifting backgrounds, expanding ripples, and a split-text distortion effect.
The mechanism relies heavily on CSS pseudo-elements (::before and ::after) attached to an HTML heading. The heading's content is dynamically pulled from its aria-label attribute (set to "Swimming"). The CSS uses clip-path to slice the text horizontally in half, applying separate 3D rotations, translations, and a slight blur to each half. This creates a wavy, refractive illusion that mimics how light bends through a liquid surface. Meanwhile, a background container animates a water-texture image, and a set of layered .ripple divs expand outward with staggered animation delays to simulate pulsing water ripples.
To use this code, simply copy the HTML snippet into an HTML file and the CSS snippet into a linked stylesheet (named styles.css to match the <link> tag). Ensure you have an internet connection so the browser can load the required external fonts and FontAwesome icons from the <head>. You can customize the displayed word by changing the aria-label="Swimming" and text properties in the HTML and CSS, allowing you to apply this fluid, refractive animation to any title or heading of your choice.