cssgradient

how to draw such gradient background using css?


enter image description here

I take a photo of sunset and I like such gredient effects from sky to highlight sunset, is there any way to simulate such effect using css? I want to erase those buildings then use it as my webpage background.

I have tried background: linear-gradient(to bottom left, rgba(96,98,139,1), rgba(230,202,224,0.8),rgba(254,255,241,0.5));, but it's not ideal


Solution

  • You can layer gradients, with different shapes, colours, opacities, and break points. Here I've done a linear gradient with 3 colours picked from your image. And then Added 3 separate radial gradients stacked on top of each other for the bright yellow centre glow, the pink glow around it, and a lighter halo around that, to attempt to soften the light from the other 2 radial gradients. You can tweak the values to get closer to what you want if it's still not quite right, and also try adding/removing elements so you can see what they are actually doing.

         body {
          height: 100vh;
          background:
            radial-gradient(
              circle at 30% 100%, 
              rgba(255, 255, 200, 1) 0%,
              rgba(255, 255, 200, 0) 20%
            ),
            radial-gradient(
              circle at 30% 100%, 
              rgba(250, 219, 234, 1) 0%,
              rgba(250, 219, 234, 0) 35%
            ),
            radial-gradient(
              circle at 30% 100%, 
              rgba(250, 219, 234, 0.3) 0%,
              rgba(250, 219, 234, 0) 50%
            ),
            linear-gradient(
              200deg, 
              rgba(92, 94, 135, 1) 0%, 
              rgba(154, 143, 175, 1) 50%, 
              rgba(255, 182, 163, 1) 100%
            );
          }