我正在尝试创建一个像这样的纯CSS波纹效果:https://codepen.io/finnhvman/pen/jLXKJw
除了我想使用透明白色作为背景色,以便能够在不同的背景上使用按钮。我唯一的问题是,涟漪效果似乎总是错误的:点击时背景变亮,展开的圆圈颜色变暗,而不是更亮的圆圈扩大。
我的代码看起来像这样:
.background{
width: 150px;
display: inline-block;
height: 50px;
background: #0066dd;
padding: 20px;
}
.color2{
background: #6600cc;
}
.button{
font-size: 24px;
color: #fff;
padding: 10px;
cursor: pointer;
transition: all 0.8s ease;
background-position: center;
}
.button:hover{
background: rgba(255, 255, 255, 0.15) radial-gradient(circle, transparent 1%, rgba(255, 255, 255, 0.15) 1%) center/15000%;
}
.button:active{
background-color: rgba(255, 255, 255, 0.5);
background-size: 100%;
transition: background 0s;
}<div class="background">
<span class="button">Button 1</span>
</div>
<div class="background color2">
<span class="button">Button 2</span>
</div>
我如何才能使效果完全相反呢?On-单击较浅的白色应从中间开始并扩展到外部。
发布于 2019-11-22 01:05:27
您可以反转作为.button:hover规则背景的radial-gradient中的颜色:
.background {
width: 150px;
display: inline-block;
height: 50px;
background: #0066dd;
padding: 20px;
}
.color2 {
background: #6600cc;
}
.button {
font-size: 24px;
color: #fff;
padding: 10px;
cursor: pointer;
transition: all 0.8s ease;
background-position: center;
}
.button:hover {
background: rgba(255, 255, 255, 0.15) radial-gradient(circle, rgba(255, 255, 255, 0.15) 1%, transparent 1%) center/15000%;
}
.button:active {
background-color: rgba(255, 255, 255, 0.5);
background-size: 100%;
transition: background 0s;
}<div class="background">
<span class="button">Button 1</span>
</div>
<div class="background color2">
<span class="button">Button 2</span>
</div>
https://stackoverflow.com/questions/58979899
复制相似问题