html画直线标刻度,用CSS划一把刻度尺

效果预览

代码展示

刻度尺

.ruler {

position: relative;

width: 70%;

margin: 20px auto;

height: 14px;

}

.ruler .cm,

.ruler .mm {

position: absolute;

border-left: 1px solid #555;

height: 14px;

width: 10%;

}

.ruler .cm:after {

position: absolute;

bottom: -15px;

font: 11px/1 sans-serif;

}

.ruler .mm {

height: 5px;

}

.ruler .mm:nth-of-type(5) {

height: 10px;

}

.ruler .cm:nth-of-type(1) {

left: 0%;

}

.ruler .cm:nth-of-type(1):after {

content: "0";

}

.ruler .cm:nth-of-type(2) {

left: 10%;

}

.ruler .cm:nth-of-type(2):after {

content: "1";

}

.ruler .cm:nth-of-type(3) {

left: 20%;

}

.ruler .cm:nth-of-type(3):after {

content: "2";

}

.ruler .cm:nth-of-type(4) {

left: 30%;

}

.ruler .cm:nth-of-type(4):after {

content: "3";

}

.ruler .cm:nth-of-type(5) {

left: 40%;

}

.ruler .cm:nth-of-type(5):after {

content: "4";

}

.ruler .cm:nth-of-type(6) {

left: 50%;

}

.ruler .cm:nth-of-type(6):after {

content: "5";

}

.ruler .cm:nth-of-type(7) {

left: 60%;

}

.ruler .cm:nth-of-type(7):after {

content: "6";

}

.ruler .cm:nth-of-type(8) {

left: 70%;

}

.ruler .cm:nth-of-type(8):after {

content: "7";

}

.ruler .cm:nth-of-type(9) {

left: 80%;

}

.ruler .cm:nth-of-type(9):after {

content: "8";

}

.ruler .cm:nth-of-type(10) {

left: 90%;

}

.ruler .cm:nth-of-type(10):after {

content: "9";

}

.ruler .cm:nth-of-type(11) {

left: 100%;

}

.ruler .cm:nth-of-type(11):after {

content: "10";

}

.ruler .mm:nth-of-type(1) {

left: 10%;

}

.ruler .mm:nth-of-type(2) {

left: 20%;

}

.ruler .mm:nth-of-type(3) {

left: 30%;

}

.ruler .mm:nth-of-type(4) {

left: 40%;

}

.ruler .mm:nth-of-type(5) {

left: 50%;

}

.ruler .mm:nth-of-type(6) {

left: 60%;

}

.ruler .mm:nth-of-type(7) {

left: 70%;

}

.ruler .mm:nth-of-type(8) {

left: 80%;

}

.ruler .mm:nth-of-type(9) {

left: 90%;

}

.ruler .mm:nth-of-type(10) {

left: 100%;

}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值