css中的counter-increment属性怎么用

发布时间:2022-02-25 13:39:42 作者:小新
来源:亿速云 阅读:101

这篇文章主要介绍css中的counter-increment属性怎么用,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

  说明

  利用这个属性,计数器可以递增(或递减)某个值,这可以是正值或负值。如果没有提供number值,则默认为1。

  注释:如果使用了"display:none",则无法增加计数。如使用"visibility:hidden",则可增加计数。

  值 描述

  none

  默认。选择器无计数器增量。

  idnumber

  id定义将增加计数的选择器、id或class。

  number定义增量。number可以是正数、零或者负数。

  inherit

  规定应该从父元素继承counter-increment属性的值。

  实例

  对部分和子部分进行编号(比如"Section1"、"1.1"、"1.2")的方法:

  <!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

  <html>

  <head>

  <styletype="text/css">

  body{counter-reset:section;}

  h2{counter-reset:subsection;}

  h2:before

  {

  counter-increment:section;

  content:"Section"counter(section)".";

  }

  h3:before

  {

  counter-increment:subsection;

  content:counter(section)"."counter(subsection)"";

  }

  </style>

  </head>

  <body>

  <p><b>注释:</b>如果已规定!DOCTYPE,那么InternetExplorer8(以及更高版本)支持counter-increment属性。</p>

  <h2>HTMLtutorials</h2>

  <h3>HTMLTutorial</h3>

  <h3>XHTMLTutorial</h3>

  <h3>CSSTutorial</h3>

  <h2>Scriptingtutorials</h2>

  <h3>JavaScript</h3>

  <h3>VBScript</h3>

  <h2>XMLtutorials</h2>

  <h3>XML</h3>

  <h3>XSL</h3>

  </body>

  </html>

css中的counter-increment属性怎么用



以上是“css中的counter-increment属性怎么用”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注亿速云行业资讯频道!

推荐阅读:
  1. css中counter-increment属性的使用方法
  2. css中的float属性怎么用

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

css

上一篇:css中border-bottom属性有什么用

下一篇:css中的border-color属性怎么用?

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》