我正在使用HighlightJS突出显示我的代码。如何重置预标签和代码标签之间的间距(标有灰色背景)?我将pre和code标签的padding和margin都设置为0,但这似乎不起作用。理想情况下,我希望代码标签占据预标签的完整高度。你能告诉我怎么做吗?
<link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.4.0/styles/color-brewer.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.4.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
<pre>
<code class="html">
<!DOCTYPE html>
<html>
<title>HTML Tutorial</title>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
</code>
</pre>
&#13;
scanf()
&#13;
答案 0 :(得分:0)
或者从代码中删除此换行符:
<pre>
<code class="html">
像这样:
<pre><code class="html">
或者您重置了这两个标签的空白属性:
pre{
background: gray;
white-space:normal;
}
pre code{
white-space:pre;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.4.0/styles/color-brewer.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.4.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
<pre>
<code class="html">
<!DOCTYPE html>
<html>
<title>HTML Tutorial</title>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
</code>
</pre>