7

I have this design from a client with two layers of gradients in a button. The tricky thing is, one of the layers has a curved edge. I've mocked up the button so you have a sense of what I'm saying, hopefully.

enter image description here

What I managed to do is a straight edge (see code snippet, color difference is not important, just need the curve). Does anyone have done this before? Or does it have to be a background image? Thanks!

P.S. I also thought about using radial gradient on a pseudo element and absolute position it, but couldn't get the exact straight edge look like the linear gradient.

a {
  background-image: linear-gradient(-155deg,rgba(74,148,214,.4) 45%,rgba(255,255,255,.08) 15%),linear-gradient(258deg,rgba(87,238,255,.1),rgba(77,108,211,.2));
  background-color: rgba(74,148,214,.9);
  color: #fff;
  width: 200px;
  height: 40px;
  border-radius: 10px;
  margin-top: 50px;
  display: block;
  text-align: center;
  line-height: 40px;
}
<a>
  Some button
</a>

0

3 Answers 3

23

You can get pretty close by using a radial-gradient instead of linear:

a {

background-image: 
  radial-gradient(ellipse farthest-corner at 0 140%, #3c84cc 0%, #316dc2 70%, #4e95d3 70%);
  color: white;
  width: 200px;
  height: 50px;
  border-radius: 10px;
  margin-top: 50px;
  display: block;
  text-align: center;
  line-height: 50px;
}
<a>
  Some button
</a>

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! I was working in that direction too. Just couldn't get the exact look I want... this looks great!
3

You can use a pseudo element to draw the curve using a circle, then just use whatever gradient you want as the background(s)

a {
    background-color: lightblue;
    color: #fff;
    width: 200px;
    height: 40px;
    border-radius: 10px;
    margin-top: 50px;
    display: block;
    text-align: center;
    line-height: 40px;
    position: relative;
    z-index: 1;
    overflow: hidden;
}
a:after {
    content: '';
    position: absolute;
    background-color: blue;
    width: 600px;
    height: 200px;
    border-radius: 50%;
    top: 0;
    left: 0;
    transform: translate(-49%,0);
    z-index: -1;
}
<a>
  Some button
</a>

1 Comment

Thanks! I was going in that direction too, but was trying to use radial gradient and couldn't get the exact look I wanted. I'll try using linear gradient on the pseudo element.
3

I just modified a bit @Blazemonger's post. I fixed the position of the curved line.

a {
  background-image: radial-gradient(ellipse farthest-corner at -10% 250%, #3c84cc 0%, #315dc2 80%, #4e95d3 80%);
  color: white;
  width: 200px;
  height: 50px;
  border-radius: 10px;
  margin-top: 50px;
  display: block;
  text-align: center;
  line-height: 50px;
} 
<a>Some button</a>

Comments

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.