标题标题不言自明。手动完成此示例:
<head>
<style>
.toc {
border: thin solid lightgray;
background-color: whitesmoke;
}
</style>
</head>
<body>
<h1>Article title</h1>
<hr />
<p>Some introductory text.</p>
<span id="toc">
<table class="toc">
<thead>
<tr>
<th>Contents</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<ol>
<li><a href="#1">Heading</a></li>
<ol>
<li><a href="#1.1">Sub-heading</a></li>
<ol>
<li><a href="#1.1.1">Sub-sub-heading</a></li>
</ol>
</ol>
<li><a href="#2">Second heading</a></li>
<ol>
<li><a href="#2.1">Second sub-heading</a></li>
<ol>
<li><a href="#2.1.1">Second sub-sub-heading</a></li>
</ol>
</ol>
<li><a href="#3">See also</a></li>
<li><a href="#4">Notes & References</a></li>
<li><a href="#5">Further reading</a></li>
<li><a href="#6">External links</a></li>
</ol>
</td>
</tr>
</tbody>
</table>
</span>
<div id="Contents">
<h1 id="1">Heading</h1>
<hr />
<h2 id="1.1">Sub-heading</h2>
<h3 id="1.1.1">Sub-sub-heading</h3>
<h1 id="2">Second heading</h1>
<hr />
<h2 id="2.1">Second sub-heading</h2>
<h3 id="2.1.1">Second sub-sub-heading</h3>
<h1 id="3">See also</h1>
<hr />
<h1 id="4">Notes & References</h1>
<hr />
<h1 id="5">Further reading</h1>
<hr />
<h1 id="6">External links</h1>
<hr />
</div>
</body>
问题:
答案 0 :(得分:0)
您可以使用forRoot(), more on that here.调整以呈现预期结果
ol {
counter-reset: section; /* Creates a new instance of the
section counter with each ol
element */
list-style-type: none;
}
li::before {
counter-increment: section; /* Increments only this instance
of the section counter */
content: counters(section, ".") " "; /* Combines the values of all instances
of the section counter, separated
by a period */
}
&#13;
<ol>
<li>item</li> <!-- 1 -->
<li>item <!-- 2 -->
<ol>
<li>item</li> <!-- 2.1 -->
<li>item</li> <!-- 2.2 -->
<li>item <!-- 2.3 -->
<ol>
<li>item</li> <!-- 2.3.1 -->
<li>item</li> <!-- 2.3.2 -->
</ol>
<ol>
<li>item</li> <!-- 2.3.1 -->
<li>item</li> <!-- 2.3.2 -->
<li>item</li> <!-- 2.3.3 -->
</ol>
</li>
<li>item</li> <!-- 2.4 -->
</ol>
</li>
<li>item</li> <!-- 3 -->
<li>item</li> <!-- 4 -->
</ol>
<ol>
<li>item</li> <!-- 1 -->
<li>item</li> <!-- 2 -->
</ol>
&#13;