Skip to content

Mimic Function

Tommy Hodgins edited this page Dec 16, 2019 · 1 revision

A custom function to copy the computed style of a given property from the first element in the document matching a selector. Use this to imitate the properties of other elements.

Syntax

--mimic(<selector>)
  • <selector> is a CSS selector to match a tag in the document from which to copy computed style property values

Usage

Use --mimic() on any property with a CSS selector to have CSS imitate the computed value of that property:

Input

.sidebar h2 {
  font-size: --mimic(main h1);
}

In this example, all of the <h2> elements inside an element with a class of .sidebar would imitate the font-size of the first <h1> element inside the <main> element.