我正在使用Google Prettify与Twitter Bootstrap.它正在工作,但由于某些原因,行号不显示.
这是标记:
<pre class="prettyprint linenums"> <ol class="linenums"> <li class="L0"> <span class="kwd">public</span> <span class="pln"> </span> <span class="kwd">override</span> <span class="pln"> </span> <span class="kwd">void</span> <span class="pln"> </span> <span class="typ">Dispose</span> <span class="pun">()</span> </li> <li class="L1"> <span class="pln"> </span> <span class="pun">{</span> </li> <li class="L2"> <span class="pln"> </span> <span class="kwd">base</span> <span class="pun">.</span> <span class="typ">Dispose</span> <span class="pun">();</span> </li> <li class="L3"> <span class="pln"> </span> <span class="pun">}</span> </li> </ol> </pre>
我称之为:
<script type="text/javascript"> $(document).ready(function () { prettyPrint(); }); </script>
我没有任何自定义CSS ..只使用Bootstrap CSS ..
解决方法
我建议你使用这2个文件:
http://twitter.github.com/bootstrap/assets/js/google-code-prettify/prettify.css
http://twitter.github.com/bootstrap/assets/js/google-code-prettify/prettify.js
并将其添加到您的页脚中:
<script> !function ($) { $(function(){ window.prettyPrint && prettyPrint() }) }(window.jQuery) </script>