-2

Here is a gradient background:

body {
  background: linear-gradient(to right, red , yellow);
}

and here is the polka dot css:

body {
  background-color: #94fcc8;
  opacity: 1;
  background-image:  radial-gradient(#7c7c50 0.9500000000000001px, transparent 0.9500000000000001px), radial-gradient(#7c7c50 0.9500000000000001px, #94fcc8 0.9500000000000001px);
  background-size: 38px 38px;
  background-position: 0 0,19px 19px;
}

how do I somehow merge it together?

here is the codepen: https://codepen.io/danichk/pen/YyVeXa

Thanks in advance.

Sam Min Wong
  • 151
  • 3
  • 18
  • `background-image` accepts a comma-delimited list of images/gradients, as do the other `background-` and `-blend-mode` properties. Order of the values does matter... – Rene van der Lende May 25 '23 at 16:01

2 Answers2

1

As commented

background-image accepts a comma-delimited list of images/gradients, as do the background-.. and ..-blend-mode properties. Order of the values does matter...

snippet

body {
  background: wheat;

  background-image: radial-gradient(salmon 20%, transparent 0), /* polka dots */
                    radial-gradient(salmon 20%, transparent 0),
                    linear-gradient(to right, red , yellow); /* your gradient */

  background-size: 30px 30px, /* polka dots */
                   30px 30px,
                   100% 100%; /* your gradient */

  background-position: 0 0, 15px 15px;
  /* Without a 3rd set of values, the 3rd gradient
     will default to the first set of values (0 0) */
}
Rene van der Lende
  • 4,992
  • 2
  • 14
  • 25
  • *your gradient not here, gets default values* --> it won't get defaults values but it will use the `0 0` you defined. The sequence is repeated until all the background-images are covered. If you used `15px 15px, 0 0` then the last gradient will use `15px 15px` – Temani Afif May 25 '23 at 19:18
0

html {
  --g:/30px 30px radial-gradient(salmon 20%, #0000 0);
  background:
    0 0 var(--g),15px 15px var(--g),
    linear-gradient(45deg,red,blue);
  min-height: 100%;
}
Temani Afif
  • 245,468
  • 26
  • 309
  • 415