我正在使用美化:
<pre class="prettyprint linenums">
some code
</pre>
它有效,但行号每 5 行显示一次,而不是每一行。我正在使用这些文件
<link href="../src/prettify.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="../src/prettify.js"></script>
基本在本页末http://google-code-prettify.googlecode.com/svn/trunk/styles/index.html你可以看到我想要的,但我看了那段代码,我想不通。
最佳答案
根本原因是list-style-type: none
in prettify.css:
/* Specify class=linenums on a pre to get line numbering */
ol.linenums { margin-top: 0; margin-bottom: 0 } /* IE indents via margin-left */
li.L0,
li.L1,
li.L2,
li.L3,
li.L5,
li.L6,
li.L7,
li.L8 { list-style-type: none /* <<< THIS is the cause! */ }
/* Alternate shading for lines */
li.L1,
li.L3,
li.L5,
li.L7,
li.L9 { background: #eee }
您可以删除该规则或覆盖它:
.linenums li {
list-style-type: decimal;
}
关于javascript - 如何为 Google Prettify 中的所有行添加行号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8399547/