4

我正在使用 Hugo 静态网站生成器来创建网站。我正在使用此代码片段,如文档中给出的创建 TOC:

<div id="toc" class="well col-md-4 col-sm-6">
    {{ .TableOfContents }}
</div>

这是生成的代码:

<div id="toc" class="well col-md-4 col-sm-6">
   <nav id="TableOfContents">
   <ul>
      <li>
         <ul>
            <li><a href="#step-1-install-hugo:c57cc0038c788519b441e0331c8bebc7">Step 1. Install Hugo</a></li>
            <li><a href="#step-2-build-the-docs:c57cc0038c788519b441e0331c8bebc7">Step 2. Build the Docs</a></li>
            <li><a href="#step-3-change-the-docs-site:c57cc0038c788519b441e0331c8bebc7">Step 3. Change the docs site</a></li>
            <li><a href="#step-4-have-fun:c57cc0038c788519b441e0331c8bebc7">Step 4. Have fun</a></li>
         </ul>
      </li>
   </ul>
   </nav>
</div>

因此,我得到了额外的子弹。谁能解决这个问题?或者你能建议 CSS 从第一个ul.

4

2 回答 2

3

使用以下 CSS:

#toc ul { 
  list-style-type: none; 
}

#toc ul ul { 
  list-style-type: disc; 
}
于 2016-05-15T16:54:14.840 回答
2

这很适合我的需要

{{ .TableOfContents | replaceRE "<ul>[[:space:]]*<li>[[:space:]]*<ul>" "<ul>" | replaceRE "</ul>[[:space:]]*</li>[[:space:]]*</ul>" "</ul>" |  safeHTML }}

连同这个CSS

nav > ul > li {
  list-style: none;
}
于 2018-06-19T02:28:44.813 回答