【CSS】计数器
抄自B站Up主CodingStartup起码课
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="./vue.min.js"></script>
<title>Document</title>
</head>
<body>
<div id="number-input">
<button @click="subtract">-</button>
<span :class="{before:isBefore, after:isAfter}" :data-before="countBefore"
:data-after="countAfter">{{count}}</span>
<button @click="add">+</button>
</div>
</body>
</html>
<script>
new Vue({
el: '#number-input',
data: {
count: 6,
isBefore: false,
isAfter: false,
},
computed: {
countBefore: function () { return this.count - 1; },
countAfter: function () { return this.count + 1; }
},
methods: {
add() {
if (!this.isAfter) {
this.isAfter = true;
setTimeout(() => {
this.count ++;
this.isAfter = false;
}, 200);
}
},
subtract() {
if (!this.isBefore) {
this.isBefore = true;
setTimeout(() => {
this.count--;
this.isBefore = false;
}, 200);
}
},
}
});
</script>
<style>
:root {
font-size: 100px;
font-size: 700;
font-family: 'Microsoft YaHei';
}
html,
body {
margin: 0;
padding: 0;
min-height: 100vh;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
}
#number-input {
width: 5rem;
height: 1rem;
background-color: #000;
border-radius: .2rem;
display: flex;
overflow: hidden;
padding: 0.3rem 0;
position: relative;
box-shadow: 0px 6px 12px rgba(0, 0, 0, 0.6);
}
#number-input::after {
content: '';
position: absolute;
top: 0;
left: 0;
background: linear-gradient(180deg, rgba(0, 0, 0, .9) 0%, rgba(0, 0, 0, 0) 30%, rgba(0, 0, 0, 0) 70%, rgba(0, 0, 0, 0.9) 100%);
width: 100%;
height: 100%;
}
#number-input span {
color: #fff;
display: block;
flex: 1 1 5rem;
line-height: 1rem;
text-align: center;
transform: translateY(-1rem);
}
#number-input span.before {
transform: translateY(0rem);
transition: transform .2s ease-in;
}
#number-input span.after {
transform: translateY(-2rem);
transition: transform .2s ease-in;
}
#number-input span::before {
display: block;
content: attr(data-before);
}
#number-input span::after {
display: block;
content: attr(data-after);
}
#number-input button {
border: none;
flex: 0 0 1.2rem;
background: none;
color: #fff;
font-size: .6rem;
line-height: 1rem;
padding: 0;
margin: 0;
width: 1rem;
height: 1rem;
position: relative;
z-index: 100;
}
</style>
【CSS】计数器的更多相关文章
- css计数器详解
什么是css计数器 体验更佳排版请戳原文链接:http://blog.liuxianan.com/css-counters.html 就是采用css给一些html元素自动生成编号,比如类似1.3.2这 ...
- CSS计数器
使用CSS计数器就像使用变量一样. 它有以下几个属性: counter-reset 创建或重置计数器 counter-increment 增长计数器 content 生成内容 counter() 将计 ...
- 转载:CSS计数器的趣味时光之css计算数据
CSS计数器是“啊太好了,竟不知道CSS可以做这啊”这类非常有趣的众多特性之一.简言之,用CSS使你持续某增加某个量,而无需JavaScript. 简单计数器 我们从这个简单的分页示例开始: 你见到的 ...
- CSS计数器的趣味时光
CSS计数器是“啊太好了,竟不知道CSS可以做这啊”这类非常有趣的众多特性之一.简言之,用CSS使你持续某增加某个量,而无需JavaScript. 简单计数器 我们从这个简单的分页示例开始: 你见到的 ...
- 排行榜妙用——CSS计数器
碰到的坑 小伙伴你们是否有碰到以下的情况,排行榜前3名的样式不一样,你们是怎么处理的么?
- CSS计数器妙用
做web的经常会遇到类似排行榜的需求, 特别是要求前n名的样式和后面人不一样. 通常大多数人对于这个需求的做法都是在后端处理好排名名次, 在前端填入内容, 然后针对前n名做特殊的样式处理. 但是这样有 ...
- CSS计数器(序列数字字符自动递增)详解———张鑫旭
by zhangxinxu from http://www.zhangxinxu.com本文地址:http://www.zhangxinxu.com/wordpress/?p=4303 一.挖坟不可耻 ...
- css计数器 及 鼠标经过从中间扩散一个矩形(正方形长方形均可)
<!DOCTYPE html> <html> <head> <title>css计数器--兼容IE8</title> <meta ch ...
- CSS计数器:counter
最近的需求,明星字体销售排行榜中,需要对字体的销售情况进行排序. 在早期,只有ol和ul可以对子元素li进行排序:如果不使用这两个标签,就由前台开发去手动填写序号. 当然,在这个需求中,数据不是实时更 ...
- CSS 计数器详解
在前端开发中总少不了列表项,对于列表项序号,射鸡师一般会列出个1,2,3...序号.在不了解css计数器属性之前,我一般会用精灵图,用类名来区分序列号图片.这样做尽管可以达到目的,但是很不方便,开发过 ...
随机推荐
- Pycharm关联gitlab(http方式)
Pycharm支持关联gitlab仓库,关联后对远端项目的克隆和提交都很方便.当初笔者在关联时遇到了很多坑,网上也没找到相关解决办法,所以在这里分享下完整的关联过程. 一.安装git 下载地址http ...
- Intouch/ifix语音报警系统制作(3-利用自定义过程和函数,重构先前版本)
在语音模块嵌入了半年左右的时间,经过实际使用发现,代码冗余,重复太多,维护较难,新增也不易,故而对整个框架进行整理,实现简单添加,维护容易的目的. 1.代码优化 1.1构建自定义过程 name 参数代 ...
- SpringBoot自动装配-源码分析
1. 简介 通过源码探究SpringBoot的自动装配功能. 2. 核心代码 2.1 启动类 我们都知道SpringBoot项目创建好后,会自动生成一个当前模块的启动类.如下: import org. ...
- GhostScript 沙箱绕过(命令执行)漏洞(CVE-2019-6116)
影响范围 Ghostscript 9.24之前版本 poc地址:https://github.com/vulhub/vulhub/blob/master/ghostscript/CVE-2019-61 ...
- [源码解析] 机器学习参数服务器 Paracel (1)-----总体架构
[源码解析] 机器学习参数服务器 Paracel (1)-----总体架构 目录 [源码解析] 机器学习参数服务器 Paracel (1)-----总体架构 0x00 摘要 0x01使用 1.1 配置 ...
- CTF中的序列化与反序列化
记一些CTF出现的序列化与反序列化的知识点和题目. 序列化和反序列化的概念 序列化就是将对象转换成字符串.字符串包括 属性名 属性值 属性类型和该对象对应的类名. 反序列化则相反将字符串重新恢复成对象 ...
- 接口的调用Client测试
先占坑,明天记录 看了个寂寞,哈哈哈
- mapboxgl 互联网地图纠偏插件(三)
先说结论,结论当然是:大功告成,喜大普奔.看效果图: 好了,接下来说一下过程 先回顾一下这个系列的第一篇和第二篇 第一篇是直接改的 mapboxgl 源码,在源码里面对瓦片的位置进行纠偏,遇到的问题是 ...
- Haskell Command-line Application Building
Haskeline Package Haskeline provides a user interface for line input in command-line programs. This ...
- 关于shell脚本——echo、for语句、while语句、until语句
目录 一.echo 1.1.echo命令用法 1.2.echo截取字符 二.for语句 2.1.实例 创建用户名文件 创建脚本文件 运行脚本 三.while语句 3.1.实例 创建脚本文件 运行脚本 ...