我将代码嵌套在一个有序列表中,作为一些队友的一组指令。但是,当我在列表项中嵌套代码块时,间距完全消失了。我的代码块中的代码从页面宽度的一半开始。这是一些示例代码:
<html>
<head>Test</head>
<body>
<ol>
<li> This is a test list item.
<pre>
<code>
def my_function(a):
return a
</code>
</pre>
</li>
<li>Element 2
</li>
</body>
</html>
最佳答案
这是因为你缩进了标记中的代码,试试这个
<ol>
<li> This is a test list item.
<pre>
<code>
def my_function(a):
return a
</code>
</pre>
</li>
<li>Element 2
</li>
</ol>
关于css - html列表项中的代码块间距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22568875/