Set a grey to white gradient
background
. Give it a small
background-size
(by default, this repeats to cover the entire element). This is the
pattern part
(small, repeating pattern parts). We could also use thin blurry stripes -
linear-gradient
, rays -
repeating-conic-gradient
, rings -
repeating-radial-gradient
. See
this demo
for examples.
Add another grey to white gradient layer covering the entire element. This is the
map part
. Where the map is
darker,
it will make the pattern
thicker
. This could even be an actual image -
url(myimg.jpg)
.
multiply
the two
background
layers. The blurry dots pattern looks now darker where the map is darker than where the map is lighter.
multiply
literally means multiply corresponding decimal representations of percentage RGB channel values (for example,
50%
grey has all channel values used in computations) for each pair of corresponding pixels in the two layers.
contrast()
with values
>1
pushes darker greys (that is, darker than a
50%
grey, which is dead in the middle between black and white) towards black and the other lighter greys towards white. A large enough value pushes them all the way to either black or white. The darker blurry dots have more of the blur around them pushed to black than the lighter ones.
background: linear-gradient(90deg, #888, #fff), radial-gradient(closest-side, #777, #fff) 0/ 1em 1em;background-blend-mode: multiply;filter: contrast(21)