首页 > 其他分享 >CSS3实现打勾(✔)效果

CSS3实现打勾(✔)效果

时间:2023-02-06 13:37:19浏览次数:64  
标签:CSS3 checkbox checked 打勾 效果 stroke animation input circle


CSS3实现打勾效果

  • ​​HTML主体​​
  • ​​我们看,这个效果的HTML结构​​
  • ​​属性:​​
  • ​​样式属性​​

关于打勾✔效果,应该都不陌生。

eg:我们在某些商场,支付的时候,支付成功会有个成功的标识,就像下面这样

CSS3实现打勾(✔)效果_css3

HTML主体

我们看,这个效果的HTML结构

​<svg>​​​标签作为画布
​​​<circle>​​​标签来画✔外围的圆
​​​<polyline>​​标签来画✔

属性:

​fill="none"​​​ 设置背景颜色为无色
​​​stroke="#68E534"​​​ 设置圆的主题颜色 同✔
​​​stroke-width="20"​​​ 设置线条的粗细
​​​stroke-linecap="round"​​​ 设置线条两端为圆角
​​​stroke-linejoin="round"​​​ 设置✔的交点为圆角
​​​points="88,214 173,284 304,138"​​ 确定✔的位置

<body>
<input type="checkbox">
<svg>
<circle class="circle" fill="none" stroke="#68E534" stroke-width="20" cx="200" cy="200" r="190"
stroke-linecap="round" transform="rotate(-90,200,200)" />
<polyline class="tick" fill="none" stroke="#68E534" stroke-width="24" points="88,214 173,284 304,138"
stroke-linecap="round" stroke-linejoin="round" />
</svg>
<h2>Success</h2>
</body>

样式属性

主流的样式设置,就不过的赘述啦

​input[type="checkbox"]:checked~h2​​​​input[type="checkbox"]:checked+svg .circle​​​​input[type="checkbox"]:checked+svg .tick​
实现联动效果(类似于js)

​@keyframes circle​​ 设置动态范围

​animation-fill-mode: forwards;​​ 必不可少的一项,因为我们在初始化的时候我们设置显示范围为不可见,这是属性是用来设置显示停留在最后时刻,这样我们就能实现只有进场动画,一个从无到有的显示效果

body {
display: flex;
justify-content: center;
align-items: center;
text-align: center;
min-height: 100vh;
flex-direction: column;
}

svg {
width: 400px;
height: 400px;
}

h2 {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
font-size: 36px;
margin-top: 40px;
color: #333;
opacity: 0;
}

input[type="checkbox"]:checked~h2 {
animation: .6s title ease-in-out;
animation-delay: 1.2s;
animation-fill-mode: forwards;
}

.circle {
stroke-dasharray: 1194;
stroke-dashoffset: 1194;
}

@keyframes circle {
from {
stroke-dashoffset: 1194;
}
to {
stroke-dashoffset: 2388;
}
}

input[type="checkbox"]:checked+svg .circle {
animation: circle 1s ease-in-out;
animation-fill-mode: forwards;
}

.tick {
stroke-dasharray: 350;
stroke-dashoffset: 350;
}

@keyframes tick {
from {
stroke-dashoffset: 350;
}
to {
stroke-dashoffset: 0;
}
}

input[type="checkbox"]:checked+svg .tick {
animation: tick 0.8s ease-in-out;
animation-fill-mode: forwards;
animation-delay: .95s;
}

@keyframes title {
from {
opacity: 0;
}
to {
opacity: 1;
}
}

下载封装好的效果

标签:CSS3,checkbox,checked,打勾,效果,stroke,animation,input,circle
From: https://blog.51cto.com/u_14316538/6038967

相关文章

  • Qt实现 剪映 桌面端的界面效果
    下方是个人实现的桌面端剪映效果,个人觉得自己实现的比较好看,原本的字体太小了再上一张桌面端剪映原版界面原本的界面实现看起来确实字体偏小不好看,因为发现原本也是Qt实......
  • [ Tcl ] 如何实现类似 Perl 中 shift 函数的效果
    https://www.cnblogs.com/yeungchie/函数功能Perl中shift函数可以返回列表的第一个元素,并将后续所有元素向前移位(索引值减1)。输入可选,默认为@_或者@ARGV。my@......
  • Cesium 加载GeoJson数据,看不到实体效果
    问题我真的不知道为什么几乎每次要用Cesium加什么东西,不管是点线面还是图层,总是不顺利要加载一个GeoJson数据,数据包含几个点,需要展示点的位置和标签名称。用以下代码,打印......
  • Axure 弹出框遮罩层灯箱效果
    灯箱效果:比较适合Web,效果不太理想,还是自己做个比较合适弹出效果:就是弹框推动效果:A元件显示的时候,把B元件往下、右移动。如Web左侧菜二级单效果......
  • Android RecyclerView实现ViewPager效果,用LinearSnapHelper
    文章目录​​LinearSnapHelper效果​​LinearSnapHelper效果SnapHelper是RecyclerView功能的一种拓展,使RecyclerView滑动行为类似ViewPager,无论怎么滑动最终停留在某页正中......
  • Qt实现 剪映 桌面端的界面效果
    下方是个人实现的桌面端剪映效果,个人觉得自己实现的比较好看,原本的字体太小了再上一张桌面端剪映原版界面原本的界面实现看起来确实字体偏小不好看,因为发现原本也是Qt实现......
  • 风筝效果小练习
    实现效果如图:<!DOCTYPEhtml><html><head><metacharset="utf-8"><title></title><style>*{margin:0;padding:0;}.mydiv{width:200px;......
  • CSS 实现文本装饰效果
    使用CSS实现文本装饰效果主要有以下几种方式:text-shadow:为文本添加阴影效果。text-decoration:为文本添加下划线、删除线、上划线等装饰效果。letter-spacing:调......
  • Web 页面如何实现动画效果
    Web页面可以使用多种方式实现动画效果,其中最常用的有两种:CSS动画:通过CSS中的transition和animation属性来实现动画效果。CSS动画实现起来简单,性能消耗小,支持广......
  • 磁疗效果因“病”而异,坚持=胜利!
    磁疗在我国具有悠久的历史早在春秋战国时期,就有神医扁鹊运用磁疗治病的记载。 北京军区总医院理疗科主任,中华生物磁学研究会秘书长周万松认为,关于磁场改善血液循环这一......