You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何让GitHub README.md中项目符号居中且符号左对齐?

解决GitHub README列表居中且项目符号左对齐的问题

问题原因

你之前的方法无效,是因为GitHub对README中的HTML样式有一定限制,且混用markdown列表符号(-)和<br>标签的方式,会导致列表结构不规范,样式无法正确生效。

有效解决方案

使用规范的HTML列表标签配合内联样式,既能让整个列表块居中,又能保证项目符号左对齐成一条竖线:

<div align="center">
  <small>
    <ul style="display: inline-block; text-align: left; margin: 0;">
      <li>Total number of months included in the dataset</li>
      <li>Net total amount of profit/losses over the entire period</li>
      <li>Average of the changes in profit/losses over the entire period</li>
      <li>Greatest increase in profits (date and amount) over the entire period</li>
      <li>Greatest decrease in losses (date and amount) over the entire period</li>
    </ul>
  </small>
</div>

代码说明

  1. <div align="center">:让整个容器内的内容水平居中
  2. <ul style="display: inline-block; text-align: left; margin: 0;">:
    • display: inline-block:让列表块根据内容宽度自适应,而非占满整行,确保能在父容器中居中
    • text-align: left:让列表内的文字和项目符号保持左对齐
    • margin: 0:去除列表默认的外边距,避免多余间距
  3. <li>标签:用规范的列表项结构,保证项目符号自然对齐

内容的提问来源于stack exchange,提问作者Elliot

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.10 12:34:55