您的位置:首页 > 汽车 > 时评 > 【前端技巧】css篇

【前端技巧】css篇

2024/7/3 17:14:57 来源:https://blog.csdn.net/Moriarty123666/article/details/139842517  浏览:    关键词:【前端技巧】css篇

利用counter实现计数器

counter-reset:为计数器设置名称,语法如下:

counter-rese: <idntifier><integer>

第一个参数为变量名称,第二个参数为初始值,默认为0

counter-increment:设置计数器增量,语法如下:

counter-increment: <idntifier><integer>

第一个参数为变量名称,第二个参数为增量,默认为1

counter():展示计数器

counter( <custom-ident>, <counter-style>? )

第一个参数为变量名称,第二个参数为计数器样式,默认为decimal

counters():展示计数器,用于计数器嵌套的场景

counters( <custom-ident>, <string>, <counter-style>? )

第一个参数为变量名称,第二个参数为分隔符, 第三个参数为计数器样式,默认为decimal

举个例子:

    <ul><li>html</li><li>css</li><li>js</li></ul>
<style>ul {counter-reset: digit 1;li {text-decoration: none;}}ul li::before {counter-increment: digit 2;content: counter(digit) ")";}
</style>

效果如下:
在这里插入图片描述

链接的状态顺序

链接4种状态:link,:visited :active :hover按LVHA的顺序声明

<style>a:link {color: yellow;}a:visited {color: green;}a:hover {color: red;}a:active {color: orange;}
</style>

在这里插入图片描述

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com