我正在尝试创建一个像这样的纯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>
我怎样才能使效果完全相反?单击时,较浅的白色应从中间开始并扩展到外部。
您可以颠倒规则radial-gradient
背景的颜色.button:hover
:
.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>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句