CSS+JS實(shí)現(xiàn)水滴漣漪動(dòng)畫按鈕效果的示例代碼
發(fā)布時(shí)間:2020-08-26 16:57:47 作者:qq_39295665
我要評(píng)論
這篇文章主要介紹了CSS+JS實(shí)現(xiàn)水滴漣漪動(dòng)畫按鈕,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友參考下吧
代碼如下所示:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.btn{
display: block;
width: 300px;
height: 100px;
margin: 50px;
outline: 0;
overflow: hidden;
position: relative;
transition: .3s;
cursor: pointer;
user-select: none;
text-align: center;
line-height: 100px;
font-size: 50px;
background: tomato;
color: #fff;
border-radius: 10px;
}
.btn>span{
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;}
.btn>span:after{
content: '';
position: absolute;
background: transparent;
border-radius:50%;
width: 100%;
padding-top: 100%;
margin-left: -50%;
margin-top: -50%;
left: var(--x,-100%);
top: var(--y,-100%);
}
.btn:active{
background: orangered;
}
.btn>input[type=checkbox]{
display: none
}
.btn>input[type=checkbox]+span:after{
animation: ripple-in 1s;
}
.btn>input[type=checkbox]:checked+span:after{
animation: ripple-out 1s;
}
@keyframes ripple-in{
from {
transform: scale(0);
background: rgba(0,0,0,.25)
}
to {
transform: scale(1.5);
background: transparent
}
}
@keyframes ripple-out{
from {
transform: scale(0);
background: rgba(0,0,0,.25)
}
to {
transform: scale(1.5);
background: transparent
}
}
</style>
</head>
<body>
<label class="btn" tabindex="1">
<input type="checkbox"><span onclick="ripple(this,event)">button</span>
</label>
</body>
<script>
function ripple(dom,ev){
console.log(ev)
var x = ev.offsetX;
var y = ev.offsetY;
dom.style.setProperty('--x',x+'px');
dom.style.setProperty('--y',y+'px');
}
</script>
</html>

到此這篇關(guān)于CSS+JS實(shí)現(xiàn)水滴漣漪動(dòng)畫按鈕效果的示例代碼的文章就介紹到這了,更多相關(guān)css水滴漣漪動(dòng)畫按鈕內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持腳本之家!
相關(guān)文章

css實(shí)現(xiàn)抖音訂閱按鈕動(dòng)畫效果
這篇文章主要介紹了css實(shí)現(xiàn)抖音訂閱按鈕動(dòng)畫效果,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-03-12
基于CSS 屬性實(shí)現(xiàn)按鈕懸停邊框和背景動(dòng)畫集合
這篇文章主要介紹了基于CSS 屬性實(shí)現(xiàn)按鈕懸停邊框和背景動(dòng)畫集合,需要的朋友可以參考下2019-05-09
這篇文章主要介紹了CSS實(shí)現(xiàn)菜單按鈕動(dòng)畫,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),需要的朋友可以參考下2019-04-12
純css實(shí)現(xiàn)Material Design中的水滴動(dòng)畫按鈕
這篇文章主要介紹了純css實(shí)現(xiàn)Material Design中的水滴動(dòng)畫按鈕的相關(guān)資料,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2018-10-26基于 CSS 動(dòng)畫的 SVG 按鈕實(shí)例代碼
本文通過實(shí)例代碼給大家介紹了基于 CSS 動(dòng)畫的 SVG 按鈕的實(shí)現(xiàn)方法,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友參考下吧2018-10-12
基于css實(shí)現(xiàn)炫酷按鈕動(dòng)畫效果案例代碼
按鈕在開發(fā)中使用的頻率非常的高,ui 框架中的按鈕組件也都是層出不窮,今天教大家僅用 css 實(shí)現(xiàn)一些非常炫酷的按鈕效果,感興趣的朋友跟隨小編一起學(xué)習(xí)吧2023-02-28






