Categories: CSS属性

CSS counter-increment 属性 | CSS教程

返回到:CSS 计数器 | CSS教程

属性定义及使用说明

counter-increment属性递增一个或多个计数器值。

counter-increment属性通常用于counter-reset属性和content属性。

默认值:none
继承:no
版本:CSS2
JavaScript 语法:object.style.counterIncrement=”subsection”

所有主流浏览器都支持counter-increment属性。

注意:IE8只有指定!DOCTYPE才支持counter-increment属性。

属性值

说明
none没有计数器将递增
id numberid 定义将增加计数的选择器、id 或 class。number 定义增量。number 可以是正数、零或者负数。
inherit指定counter-increment属性的值,应该从父元素继承

实例

对部分和子部分进行编号(比如 “Section 1″、”1.1″、”1.2″)的方法:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Web176教程网(web176.com)</title>
<style>
body {counter-reset:section;}
h1 {counter-reset:subsection;}
h1:before
{
 counter-increment:section;
 content:"Section " counter(section) ". ";
}
h2:before 
{
 counter-increment:subsection;
 content:counter(section) "." counter(subsection) " ";
}
</style>
</head>

<body>

<p><b>注意:</b> 仅当 !DOCTYPE已经定义 IE8支持 这个属性.</p>

<h1>HTML tutorials</h1>
<h2>HTML Tutorial</h2>
<h2>XHTML Tutorial</h2>
<h2>CSS Tutorial</h2>

<h1>Scripting tutorials</h1>
<h2>JavaScript</h2>
<h2>VBScript</h2>

<h1>XML tutorials</h1>
<h2>XML</h2>
<h2>XSL</h2>

</body>
</html>
terry

这个人很懒,什么都没有留下~

Share
Published by
terry

Recent Posts

在 Chrome 中删除、允许和管理 Cookie

您可以选择删除现有 Cooki…

3 小时 ago

自定义指令:聊聊vue中的自定义指令应用法则

今天我们来聊聊vue中的自定义…

1 周 ago

聊聊Vue中@click.stop和@click.prevent

一起来学下聊聊Vue中@cli…

2 周 ago

Nginx 基本操作:启动、停止、重启命令。

我们来学习Nginx基础操作:…

2 周 ago

Vue3:手动清理keep-alive组件缓存的方法

Vue3中手动清理keep-a…

3 周 ago

聊聊React和Vue组件更新的实现及区别

React 和 Vue 都是当…

4 周 ago