3D✨ Premium

Portal Effect

A 140 px indigo ring spins in 6 s, a lighter arc making its rotation visible, around a glowing violet core that breathes in 3 s, and twelve particles scattered around it twinkle each at its own pace: a portal to another dimension, in CSS plus a few lines of JavaScript that place the particles — one instance per copy, and a still portal when the user reduces motion.

CSSJSPortal

Updated

This effect is part of Effect.Labs — 840 vanilla effects, some free, some premium. 3D has 50 effects, including 8 free. Explore the category →

3 usage examples

The way to the secret level — indie platformer presentation page — Portal Effect example 1

① The way to the secret level — indie platformer presentation page

WhenPage for the game "Moss & Pebble": on a pixel-art stone wall, above the grassy ground, the portal floats in front of the hero, with the title "Level 7-B: find the hidden entrance".
WhyThe breathing core draws the eye to the center like an active passage, and the golden particles stand for magic dust; it is a piece of the game's scenery, not an interface.
Settings.xr-portal frame set to 300 × 230 px for a round crown; particles recolored yellow #fde047 with a golden glow; original ring and core; scenery in CSS gradients and a monospace font.
The fairy ring in the forest — interactive story for children — Portal Effect example 2

② The fairy ring in the forest — interactive story for children

WhenPage 6 of the story: in a clearing between fir trees, a ring of glowing mushrooms surrounds a pale green core, fireflies twinkle around it, and the text invites: "Click the circle to enter fairyland".
WhyThe slow pulse and the scattered points of light set up the magic without loud effects; the slow rotation of the mushroom ring brings the clearing to life.
SettingsRing as a 6 px pale yellow dotted border (border: 6px dotted), top arc almost white to keep the rotation visible; pale green gradient core; light green glowing particles; 300 × 250 px frame.
Focus point for an online hypnosis session — practitioner's page — Portal Effect example 3

③ Focus point for an online hypnosis session — practitioner's page

WhenPlayer for a 15-minute session, on a night background: the portal in the center, the instruction "Look at the light in the center and let your breathing follow its rhythm" and the progress bar below.
WhyThe core's 3 s breathing gives a rhythm to follow; slowed down, the ring and particles stay in the periphery and do not catch the eye.
SettingsOriginal colors; ring rotation slowed to 14 s (animation-duration) and twinkle to 5 s; core breathing kept at 3 s; 300 × 220 px frame.

How it works

The .fx-0047-root root (background #0a0a0f, at least 300 px tall) holds .xr-portal, a frame that takes the full width, clips what sticks out and centers the ring. .xr-portal-ring is a 140 px circle with a 3 px indigo edge at 60%, except the top arc, lavender at 95% (border-top-color): the ring makes a full turn in 6 s at constant speed, and that light arc is what makes the rotation visible; a uniform edge spinning looks still. Inside the ring, .xr-portal-inner, a 110 px disc in a violet radial gradient, breathes over 3 s: it grows by 10% and goes from 50 to 80% opacity, then back.

The JavaScript does one thing: for each .fx-0047-root on the page, it finds its .xr-portal and adds twelve .xr-portal-particle elements, 4 px #6366f1 dots with a glow. They are spread in a circle, one every 30°, at a random distance between 37.5 and 45% of the frame's width and height, with a random starting opacity too. Each twinkles over 2.4 s (scale from 0.6 to 1.5 and opacity from 20 to 100%) with a random negative delay: the twelve never light up together. No id, no global variable: two portals on a page each get their twelve particles (measured in Chromium 151, Firefox 153 and WebKit 26).

The positions are percentages of the .xr-portal frame, so their shape depends on its size. By default it takes the root's full width but only the ring's height (140 px); the particles then draw a very flat ellipse, wide and low. Give the frame a fixed size, for example 300 × 230 px as in the examples, for a rounder crown. The script runs once, when it is read: put it after the HTML, or use defer.

Accessibility

  • Reduced motion: under prefers-reduced-motion: reduce, a block scoped to .fx-0047-root stops the ring, freezes the core mid-breath (scale 1.05, 65% opacity) and turns off the twinkle: the particles stay in place with their random opacity. Measured: 0% of pixels change over 0.8 s in Chromium, Firefox and WebKit, versus 0.9 to 1.3% in normal mode.
  • Decorative content: the portal is made of empty divs that screen readers ignore. If the portal is clickable (go to the next level, next page of a story), wrap it in a real link or button with text, such as "Enter fairyland".
  • Contrast: the indigo ring measures 4.4:1 on the dark background, above the 3:1 threshold for graphical elements; the particles are deliberately faint. On a light background, darken the ring.
  • Rhythm: 6 s rotation, 3 s breathing, staggered 2.4 s twinkles; no light flashes all at once.

Browser compatibility

CSS (transform and opacity animations) + 18 lines of dependency-free ES5 JavaScript. Measured in Chromium 151, Firefox 153 and WebKit 26 (Safari's engine): 0 errors, no global variable added, twelve particles in each of two copies, same stop under reduced motion. Not checked on a real Safari.

Chrome✓ Full
Firefox✓ Full
Safari✓ WebKit 26 measured, Safari not checked
Edge✓ Full
Mobile iOS✓ Not checked on a device
Android Chrome✓ Full

Without JavaScript, the portal stays whole (spinning ring, breathing core) but has no particles. If the script loads before the HTML, it finds no root: put it after, or use defer.

The code

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

index.html — structure
<div class="fx-0047-root">
  <div class="xr-portal">
    <div class="xr-portal-ring">
      <div class="xr-portal-inner"></div>
    </div>
    <!-- + 12 <div class="xr-portal-particle"> added by the JS -->
  </div>
</div>

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

Customize

Options passed to the API or data-* attributes:

Option / propertyDefaultEffect
Particle frame size (CSS — .xr-portal) Full width, ring height (140 px) Particles are placed in percentages of the frame: give it a fixed size (width: 300px; height: 230px) for a round crown around the ring.
Colors (CSS — ring, light arc, core, particles) Indigo rgba(99,102,241,.6), lavender arc, violet core, #6366f1 particles Keep one arc clearly lighter than the rest of the edge (border-top-color), otherwise the rotation no longer shows.
Rotation speed (CSS — 6s on .xr-portal-ring) 6 s per turn 14 s for a soothing portal, 3 s for a vortex. The core turns with the ring, invisibly: its gradient is round.
Core breathing (CSS — 3s on .xr-portal-inner) 3 s, +10%, 50 → 80% opacity It is the effect's main rhythm: 4 to 5 s for calm breathing, 1.5 s for an unstable portal.
Number and distance of particles (JS) 12 particles, at 37.5-45% of the frame Change 12 in both places in the loop (i < 12 and i / 12), and 75 + Math.random() * 15 to bring them closer or push them out.
Twinkle (CSS — fx0047Twinkle 2.4s) 2.4 s, scale 0.6 → 1.5, opacity 20 → 100% Slower (5 s) for calm scenery. If you change the duration, also change 2.4 in the JavaScript, which draws the delays within that range.

FAQ

A circle with a uniform edge spinning on itself looks the same at every moment: the rotation exists but cannot be seen. The lighter top arc (border-top-color) is the landmark: you see it go around in 6 s. If you recolor the ring, keep that difference, or use a dotted edge as in the story example.
Yes. The script goes through every .fx-0047-root and finds the frame by its class, with no id: each portal gets its twelve particles. Measured with two copies in Chromium, Firefox and WebKit: twelve particles and fourteen animations in each, no errors.
Holographic Display is a square frame to project content in; Spatial Audio Dir is an indicator that shows a direction. Portal Effect is a scenery object: a passage, with a center that draws the eye and particles around it. For an entrance, a secret level, a magic threshold or a focus point, use Portal Effect.