html+css实现点赞特效的示例代码(冬春救助流程)
生活随笔
收集整理的這篇文章主要介紹了
html+css实现点赞特效的示例代码(冬春救助流程)
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
本文主要介紹了html+css實(shí)現(xiàn)點(diǎn)贊特效的示例代碼,分享給大家,具體如下:
html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
<title>純CSS實(shí)現(xiàn)點(diǎn)贊的動(dòng)畫效果</title>
<link rel="stylesheet" href="./index.css">
</head>
<body>
<label for="checkbox">
<input type="checkbox" id="checkbox" hidden>
<svg t="1639041971928" class="1606-3e89-17c3-64c5 icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3128"><path d="M512 896a42.666667 42.666667 0 0 1-30.293333-12.373333l-331.52-331.946667a224.426667 224.426667 0 0 1 0-315.733333 223.573333 223.573333 0 0 1 315.733333 0L512 282.026667l46.08-46.08a223.573333 223.573333 0 0 1 315.733333 0 224.426667 224.426667 0 0 1 0 315.733333l-331.52 331.946667A42.666667 42.666667 0 0 1 512 896z" p-id="3129" id="heart"></path></svg>
<span></span>
</label>
</body>
</html>
css
*{
/* 初始化 */
margin: 0;
padding: 0;
}
body{
/* 100%窗口高度 */
height: 100vh;
/* 彈性布局 居中 */
display: flex;
justify-content: center;
align-items: center;
/* 自定義屬性,可通過var函數(shù)對其調(diào)用 */
--c: #ff6b81;
}
svg{
width: 200px;
/* 相對定位 */
position: relative;
/* z-index: 10; */
}
#heart{
/* 填充顏色 */
fill: #eee;
/* stroke屬性可應(yīng)用于任何種類的線條,文字和元素,就像一個(gè)圓的輪廓 */
stroke: var(--c);
/* 線條寬度 */
stroke-width: 40px;
/* 設(shè)置線條為虛線,虛線的長度 */
stroke-dasharray: 2600;
/* 線條的位移 */
stroke-dashoffset: 2600;
/* 端點(diǎn)為圓頭 */
stroke-linecap: round;
}
span{
display: block;
width: 24px;
height: 24px;
background-color: transparent;
border-radius: 50%;
/* 絕對定位 居中 */
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%) scale(0);
/* 設(shè)置各個(gè)方向的陰影 */
/* 通過var函數(shù)調(diào)用自定義屬性--c,設(shè)置陰影顏色 */
box-shadow: 0 -160px 0 var(--c),
0 160px 0 var(--c),
-160px 0 0 var(--c),
160px 0 0 var(--c),
-120px -120px 0 var(--c),
120px -120px 0 var(--c),
120px 120px 0 var(--c),
-120px 120px 0 var(--c);
}
/* 勾選復(fù)選框執(zhí)行各個(gè)動(dòng)畫 */
#checkbox:checked + svg #heart{
/* 執(zhí)行動(dòng)畫: 動(dòng)畫名 時(shí)長 線性的 停留在最后一幀 */
animation: drawHeart 1s linear forwards;
}
#checkbox:checked ~ span{
/* 執(zhí)行動(dòng)畫: 動(dòng)畫名 時(shí)長 加速后減速 停留在最后一幀 */
animation: blink 0.5s ease-in-out forwards;
/* 動(dòng)畫延遲時(shí)間 */
animation-delay: 0.85s;
}
#checkbox:checked + svg{
/* 執(zhí)行動(dòng)畫: 動(dòng)畫名 時(shí)長 線性的 停留在最后一幀 */
animation: beat 1s linear forwards;
}
label{
/* 鼠標(biāo)移入,光標(biāo)變小手 */
cursor: pointer;
}
/* 定義動(dòng)畫 */
/* 畫心的動(dòng)畫 */
@keyframes drawHeart {
0%{
stroke-dashoffset: 2600;
}
80%{
fill: #eee;
stroke-dashoffset: 0;
}
100%{
fill: var(--c);
stroke-dashoffset: 0;
}
}
/* 小圓點(diǎn)閃出的動(dòng)畫 */
@keyframes blink {
0%{
transform: translate(-50%,-50%) scale(0.5);
opacity: 0.8;
}
50%{
transform: translate(-50%,-50%) scale(1);
opacity: 1;
}
100%{
transform: translate(-50%,-50%) scale(1.1);
opacity: 0;
}
}
/* 心跳動(dòng)的動(dòng)畫 */
@keyframes beat {
0%{
transform: scale(1);
}
70%{
transform: scale(1);
}
80%{
transform: scale(1.2);
}
100%{
transform: scale(1);
}
}
到此這篇關(guān)于html+css實(shí)現(xiàn)點(diǎn)贊特效的示例代碼的文章就介紹到這了,更多相關(guān)html css點(diǎn)贊特效內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持腳本之家!
總結(jié)
以上是生活随笔為你收集整理的html+css实现点赞特效的示例代码(冬春救助流程)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 极米任意门如何增加
- 下一篇: 荣耀平板X8Pro怎么多开微信 荣耀平板