最近做网页需求是让数字滚动,在网上找到了一款非常简单的插件countUP,简单实用、废话不说直接上代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<div id="box"></div>
<script src="https://cdn.bootcss.com/countup.js/1.9.3/countUp.js"></script>
<script type="text/javascript">
var options = {
useEasing: true,
useGrouping: true,
separator: ',',
decimal: '.',
};
var demo = new CountUp('box', 0, 1000, 0, 10, options); //容器id、开始数字、结束数字,小数点位数,所用时间
if (!demo.error) {
demo.start();
} else {
console.error(demo.error);
}
</script>
</body>
</html>
本文介绍了一款名为CountUp的轻量级插件,用于在网页中实现数字滚动的效果。通过简单的代码示例,展示了如何使用该插件设置数字的起始值、结束值、小数点位数及滚动时间,适用于各种网页需求。
9771

被折叠的 条评论
为什么被折叠?



