<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/randomly-place-an-element-along-edge-of-another-element-master-dev-blog-s8zowbf9a" -->

---
title: Randomly Place an Element Along Edge of Another Element...
description: A CSS technique demonstrates animating an element along the border of its parent using offset-path: border-box combined with offset-distance, inspired by a...
canonical: https://daily.dev/posts/randomly-place-an-element-along-edge-of-another-element-master-dev-blog-s8zowbf9a
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Randomly Place an Element Along Edge of Another Element – Master.dev Blog | daily.dev
og:description: A CSS technique demonstrates animating an element along the border of its parent using offset-path: border-box combined with offset-distance, inspired by a...
og:url: https://daily.dev/posts/randomly-place-an-element-along-edge-of-another-element-master-dev-blog-s8zowbf9a
og:image: https://api.daily.dev/og/posts/S8ZowBF9A.png
og:image:alt: Randomly Place an Element Along Edge of Another Element – Master.dev Blog
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Randomly Place an Element Along Edge of Another Element – Master.dev Blog

**[Frontend Masters](https://daily.dev/sources/frontendmasters)** · 4 min read · 3 upvotes · 0 comments

## Summary

A CSS technique demonstrates animating an element along the border of its parent using offset-path: border-box combined with offset-distance, inspired by a cute crab animation. Using CSS's new random() function (supported in Safari, behind a flag in Chrome) with unique seed values per keyframe allows an element to move to pseudo-random positions along that path without JavaScript. The piece walks through building a simple circle example, a glowing orb variant, and a more elaborate animated dog, noting a quirk where random() without unique seeds produces identical values across keyframes.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://blog.master.dev/randomly-place-an-element-along-edge-of-another-element>

## Questions this post answers

### Why doesn't CSS random() produce different values across multiple keyframes in the same animation?

Without a unique seed, calls to random() within the same @keyframes block appear to resolve to the same value across all keyframe steps. Giving each offset-distance declaration its own custom-ident seed, like random(--k1, 0%, 200%), random(--k2, 0%, 200%), and so on for each keyframe percentage, makes each step produce an independent random value so the element actually moves.

_Developers experimenting with CSS random() animations can track browser support quirks like this on daily.dev._

### How do I animate an element along the border of its parent container using pure CSS?

Set offset-path: border-box on the child element instead of defining a custom path, then animate offset-distance as a percentage to move it around that border. This avoids manually calculating a path with rect() matching the parent's pixel dimensions, and it stays responsive automatically since the border-box path adapts to the parent's size.

_Anyone building CSS-only motion effects can find offset-path techniques like this on daily.dev._

## Similar posts on daily.dev

- [More CSS random\(\) Learning Through Experiments – Frontend Masters Blog](https://daily.dev/posts/more-css-random-learning-through-experiments-frontend-masters-blog-74bldwjii) · Frontend Masters · 4 upvotes · 0 comments
- [Embracing Playful Imperfection With The CSS random\(\) Function — Smashing Magazine](https://daily.dev/posts/embracing-playful-imperfection-with-the-css-random-function-smashing-magazine-cwvipesbh) · Smashing Magazine · 0 upvotes · 1 comments
- [Experimenting with random\(\) in CSS](https://daily.dev/posts/experimenting-with-random-in-css-ouj2w2eta) · Polypane · 16 upvotes · 6 comments

---

Tags: [#css](https://daily.dev/tags/css)

[View this post on daily.dev](https://daily.dev/posts/randomly-place-an-element-along-edge-of-another-element-master-dev-blog-s8zowbf9a)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Randomly Place an Element Along Edge of Another Element – Master.dev Blog","url":"https://daily.dev/posts/randomly-place-an-element-along-edge-of-another-element-master-dev-blog-s8zowbf9a","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/randomly-place-an-element-along-edge-of-another-element-master-dev-blog-s8zowbf9a"},"datePublished":"2026-09-25T16:08:32.581Z","dateModified":"2026-09-25T16:08:53.839Z","description":"A CSS technique demonstrates animating an element along the border of its parent using offset-path: border-box combined with offset-distance, inspired by a...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/f4b826f2eefee3ac7061d17290cd12bf?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/f4b826f2eefee3ac7061d17290cd12bf?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Frontend Masters","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Frontend Masters","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/d34dd87208f24090bfb0917307fcf89f","url":"https://daily.dev/sources/frontendmasters"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/randomly-place-an-element-along-edge-of-another-element-master-dev-blog-s8zowbf9a","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":3},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"css","timeRequired":"PT4M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Frontend Masters","item":"https://daily.dev/sources/frontendmasters"},{"@type":"ListItem","position":3,"name":"Randomly Place an Element Along Edge of Another Element – Master.dev Blog"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/randomly-place-an-element-along-edge-of-another-element-master-dev-blog-s8zowbf9a#faq","mainEntity":[{"@type":"Question","name":"Why doesn't CSS random() produce different values across multiple keyframes in the same animation?","acceptedAnswer":{"@type":"Answer","text":"Without a unique seed, calls to random() within the same @keyframes block appear to resolve to the same value across all keyframe steps. Giving each offset-distance declaration its own custom-ident seed, like random(--k1, 0%, 200%), random(--k2, 0%, 200%), and so on for each keyframe percentage, makes each step produce an independent random value so the element actually moves. Developers experimenting with CSS random() animations can track browser support quirks like this on daily.dev."}},{"@type":"Question","name":"How do I animate an element along the border of its parent container using pure CSS?","acceptedAnswer":{"@type":"Answer","text":"Set offset-path: border-box on the child element instead of defining a custom path, then animate offset-distance as a percentage to move it around that border. This avoids manually calculating a path with rect() matching the parent's pixel dimensions, and it stays responsive automatically since the border-box path adapts to the parent's size. Anyone building CSS-only motion effects can find offset-path techniques like this on daily.dev."}}]}
```

