Toggle navigation
☰
HTML
CSS
Scripting
Database
<!DOCTYPE html> <title>My Example</title> <style> .comparison-wrapper { display: flex; gap: 40px; justify-content: center; flex-wrap: wrap; padding: 20px 0; } .ray-box { position: relative; width: 150px; height: 150px; background-color: #e9ecef; border: 2px solid #343a40; } .ray-box::before { content: attr(data-label); position: absolute; top: -25px; left: 0; width: 100%; text-align: center; font-family: sans-serif; font-size: 0.85em; font-weight: bold; white-space: nowrap; } .moving-element { width: 40px; height: 40px; color: white; display: flex; align-items: center; justify-content: center; font-family: sans-serif; font-size: 0.7em; font-weight: bold; border-radius: 50%; position: absolute; top: 50%; left: 50%; animation: shootRayCompare 2.5s ease-in-out infinite alternate; } /* Without contain: Shoots out of the box */ .no-contain { background-color: #d9534f; offset-path: ray(135deg farthest-corner); } /* With contain: Stops at the corner */ .with-contain { background-color: #5cb85c; offset-path: ray(135deg farthest-corner contain); } @keyframes shootRayCompare { 0% { offset-distance: 0%; } 100% { offset-distance: 100%; } } </style> <div class="comparison-wrapper"> <div class="ray-box" data-label="Without contain"> <div class="moving-element no-contain">Out</div> </div> <div class="ray-box" data-label="With contain"> <div class="moving-element with-contain">In</div> </div> </div>