1

I'm trying to get better at CSS, I asked my friend to draw a website in photoshop, and she threw me a stumper. This is the background I'm trying to replicate:

A gradient using shrinking circles

I found a sample on making a Pure CSS Halftone Pattern, and have adapted it as such:

#circleBackground {
    z-index: 0;
    position: relative;
    margin: -10px;
    height: 100vh;
    background: #7ecafb;
    --mask: linear-gradient(to bottom right, #7ecafb, rgba(0,0,0, 0.45));
}

    #circleBackground::before {
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        background: radial-gradient(#4f87d0, #7ecafb) 0 0/1em 1em space;
        -webkit-mask: var(--mask);
        mask: var(--mask);
        content: '';
    }
<body>
    <div id="circleBackground"></div>
</body>

which gives me this:

Some fuzzy circles that get a little smaller

I'm clearly barking up the wrong tree. The shapes aren't even close. The gradient is not happening either.

Is it possible to replicate this gradient in css? If it is, what should I look at to achieve the desired result?

5
  • Could you post the html part too Commented May 17, 2020 at 13:45
  • 1
    Html is simply <div id="circleBackground"></div> @JithinB. The filters get screwed up because of the css contrast filter. Commented May 17, 2020 at 13:59
  • 1
    I meant the colors Commented May 17, 2020 at 14:04
  • Right on both counts @user125661 - reducing the contrast kills my circles, but at least it's not teal anymore. Commented May 17, 2020 at 14:11
  • P.S. This is purely academic, I think. The 'real world' answer is to contact the designer and get svgs for their stupid complicated patterns. Commented May 17, 2020 at 17:32

1 Answer 1

1

Try this , I guess it should look almost simiar to the image you have posted:

#circleBackground {
    position: relative;
    height: 90vh;
    box-shadow: 2px 2px 5px;
    background: linear-gradient(to right, #3278f6, #80cbf9 );
    filter: contrast(7);
    --mask: linear-gradient(red, #{rgba(#000, .45)});
}

#circleBackground::before {
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    background: radial-gradient(#3278f6, transparent) 0 0/ 1em 1em space;
    -webkit-mask: var(--mask);
    mask: var(--mask);
    content: ''
}
Sign up to request clarification or add additional context in comments.

3 Comments

Thank you, with a few tweaks (turning the contrast off) it does get pretty close. Except with the contrast off it looks like squares instead of circles.
Welcome, Happy to help you. Anything more I can do to make it better ?
Well, choosing between colors or not-quite-right shapes is not the goal. I think this approach of making a circle background is wrong for this use case - probably why the original code was in black and white.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.