Distortion✨ Premium

Laser Beam

Three rainbow laser beams stretching and retracting in turn inside a dark frame, behind a glowing word.

CSSAnimationSci-Fi

Updated

This effect is part of Effect.Labs — 840 vanilla effects, some free, some premium. Distortion has 31 effects, including 5 free. Explore the category →

3 usage examples

Hero of a laser tag arena (Fulgorane) — Laser Beam example 1

① Hero of a laser tag arena (Fulgorane)

WhenThe box fills the whole hero; the arena's name replaces "LASER" in the centre, with the menu above, game length below and booking buttons at the bottom.
WhyBeams shooting out and pulling back speak directly of the game, and the neon name becomes the page's logo.
Settings--lsb-w: 100%, --lsb-h: 360px, square corners, box background #06050f, word at 2.9 rem with 8 px spacing, root with no background or minimum height.
Scanner aiming beams in an inventory app (Quarvelle) — Laser Beam example 2

② Scanner aiming beams in an inventory app (Quarvelle)

WhenIn the camera viewfinder, over the barcode on a carton, three red lines stretch and retract while the app looks for the code; the list of items already counted sits on the right.
WhyThe continuous motion shows the scanner is active, in the red everyone links with barcode readers.
SettingsTransparent 182×60 px box with no word, --lsb-spectrum cut down to reds, 3 and 1 px beams, 1.6 s cycle.
Cutting started in a laser-cutting workshop configurator (Taillandrin) — Laser Beam example 3

③ Cutting started in a laser-cutting workshop configurator (Taillandrin)

WhenAfter a click on "Start cutting", the beams settle over the darkened preview of the wooden plate with the progress percentage in the middle; the button greys out until the end.
WhyYou see the machine "working" on your own design, and the progress takes the place of the glowing word.
Settings300×324 px box with a rgba(12,10,22,.55) background laid over the preview, word replaced by the percentage (1.05 rem), 2.2 s cycle. The percentage and showing the box after the click come from the page.

How it works

The .lsb-box (300×200 px, #050510 background, 16 px corners) hides whatever overflows. It holds three horizontal .lsb-beam elements: a 4 px one in the middle and two 2 px ones at 30% and 70% of the height. Each is painted with a gradient going from transparent through red, orange, yellow, green, cyan, blue, violet and magenta, then back to transparent.

Around each beam, two blurred copies of the same colours (::before at 15 px blur, ::after at 30 px) make the glow. The lsbMove animation (3 s) shrinks it to 30% of its length, slightly left of centre and half transparent, then stretches it across the full width at full brightness. The top beam is offset by half a cycle and the bottom one by a quarter, so the three never reach full length at the same moment.

The .lsb-text word ("LASER") sits above the beams, in white with a white, cyan and magenta glow. It is optional: without it, only the beams remain. The beams do not sweep the screen from top to bottom; they stay at their height.

Accessibility

  • Real text: the word is HTML text that reads normally; the three beams are hidden from screen readers (aria-hidden="true").
  • Reduced motion: with prefers-reduced-motion: reduce the beams stay stretched across the full width and stop moving (measured: 6 looping animations → 0 for two copies).
  • No flashing: brightness changes by half over 1.5 s, gradually; no sudden burst.
  • Contrast: white text on #050510 exceeds 19:1; its coloured glow only hurts legibility at very small sizes.
  • No interaction: nothing reacts to hover, click or keyboard.

Browser compatibility

CSS only, no JavaScript. Measured in Chromium 151, Firefox 153 and Playwright's WebKit 26.5: 0 errors, two independent copies, nothing overflowing at 390 px, beams frozen under reduced motion. Minimum versions come from the inset property used by the glows.

Chrome 87+✓ Full (measured)
Firefox 66+✓ Full (measured)
Safari 14.1+✓ Full (measured in Playwright's WebKit)
Edge 87+✓ Full (Chromium engine)
Safari iOS 14.5+✓ Full (same engine as Safari)
Chrome Android 87+✓ Full (Chromium engine)

Without filter the beams show as sharp lines with no glow; their motion is kept.

The code

HTML structure to paste into your page (the CSS + JS come with your purchase):

index.html — structure
<div class="fx-0270-root">
  <div class="lsb-box">
    <div class="lsb-beam" aria-hidden="true"></div>
    <div class="lsb-beam lsb-beam-2" aria-hidden="true"></div>
    <div class="lsb-beam lsb-beam-3" aria-hidden="true"></div>
    <span class="lsb-text">LASER</span>
  </div>
</div>

One-time payment, no subscription — the code is yours forever

Customize

Options passed to the API or data-* attributes:

Option / propertyDefaultEffect
--lsb-w and --lsb-h 300px and 200px Box size; 100% to follow the container (never wider than it).
--lsb-panel #050510 Box background; transparent or a see-through tint to lay the beams over an image.
--lsb-spectrum rainbow gradient with transparent ends Colour of the beams and their glow: a gradient of reds for a code reader, greens for a game screen.
--lsb-main and --lsb-side 4px and 2px Thickness of the middle beam and of the two side beams.
--lsb-speed 3s Length of one cycle; the side beams' offset follows automatically.
--lsb-text and --lsb-font #fff and 1.5rem Colour and size of the central word (remove .lsb-text to keep only the beams).
--lsb-radius 16px Corner rounding of the box.
--lsb-bg and --lsb-min-h #0a0a0f and 300px Root background and minimum height; transparent and 0 to fit it into your page.

FAQ

No. Each beam stays at its height (30%, 50% and 70%) and only stretches and retracts horizontally. A vertical sweep would need a different animation.
Replace --lsb-spectrum with a one-hue gradient, keeping the ends transparent, for example linear-gradient(90deg, transparent, #ff2a2a 15%, #ff6a5a 50%, #ff2a2a 85%, transparent). The glows take the same colour.
Yes, .lsb-text takes any short text, such as a brand name or a percentage updated by your script. It always stays above the beams.