簡體   English   中英

html列表項中的代碼塊間距

[英]Code block spacing within an html list item

我將代碼嵌套在有序列表中,作為一些隊友的一組說明。 但是,當我將代碼塊嵌套在列表項中時,間隔完全消失了。 我的代碼塊中的代碼從頁面寬度的一半開始。 這是一些示例代碼:

<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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM