Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

291
Views
How to get this ripple effect when changing button color?

I'm just too dumb to get the same effect of the white button on the dark one. Could you explain to me the thought process to get the effect on any background color? Ideally I would like to get a ripple effect of whiteish or greyish color that works on every background. Credits to the original one https://codepen.io/finnhvman/pen/jLXKJw

/* Button style */
.btn-light {
  border: none;
  border-radius: 2px;
  padding: 12px 18px;
  font-size: 16px;
  text-transform: uppercase;
  cursor: pointer;
  color: black;
  background-color: white;
  box-shadow: 0 0 4px #999;
  outline: none;
}

.btn-dark{
  border: none;
  border-radius: 2px;
  padding: 12px 18px;
  font-size: 16px;
  text-transform: uppercase;
  cursor: pointer;
  color: white;
  background-color: black;
  box-shadow: 0 0 4px #999;
  outline: none;
}

/* Ripple effect */
.ripple {
  background-position: center;
  transition: background 0.8s;
}

.ripple-light:hover {
  background: transparent radial-gradient(circle, transparent 1%, white 1%) center/15000%;
}
.ripple-light:active {
  background-color: grey;
  background-size: 100%;
  transition: background 0s;
}

.ripple-dark:hover {
  background: transparent radial-gradient(circle, transparent 1%, dark 1%) center/15000%;
}
.ripple-dark:active {
  background-color: grey;
  background-size: 100%;
  transition: background 0s;
}
<button class="btn-light ripple ripple-light">Button</button>
<button class="btn-dark ripple ripple-dark">Button</button>

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Use CSS variable to define the colors:

/* Button style */
.btn {
  border: none;
  border-radius: 2px;
  padding: 12px 18px;
  font-size: 16px;
  text-transform: uppercase;
  cursor: pointer;
  color: black;
  background-color: var(--c);
  box-shadow: 0 0 4px #999;
  outline: none;
}
.light {
  --c: #fff;
  color:#000;
}
.dark {
  --c: #000;
  color:#fff;
}
/* Ripple effect */
.ripple {
  background-position: center;
  transition: background 0.8s;
}
.ripple:hover {
  background: var(--c) radial-gradient(circle, #0000 1%, var(--c) 1%) center/15000% ;
}
.ripple:active {
  background-color: grey;
  background-size: 100%;
  transition: background 0s;
}
<button class="btn light ripple">Button</button>
<button class="btn dark ripple">Button</button>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!