如何将列表内容向左对齐?

时间:2020-05-11 09:16:26

标签: html css list

我正在尝试将列表内容向左对齐,但是还不太清楚。在此先感谢您的任何建议。这是代码示例:

    <div class="col-md-4 mb-1">
        <i class="fas fa-hiking fa-4x"></i>
        <h4 class="my-4" font-weight-bold>What to bring</h4>
        <p>
            <ul style="list-style-type:none;">
                <li>Coffee</li>
                <li>Tea</li>
                <li>Milk</li>
            </ul>
        </p>
    </div>

2 个答案:

答案 0 :(得分:2)

padding-left: 0;设置ul

ul {
  padding: 0;
}
<div class="col-md-4 mb-1">
  <i class="fas fa-hiking fa-4x"></i>
  <h4 class="my-4" font-weight-bold>What to bring</h4>
  <p>
    <ul style="list-style-type:none;">
      <li>Coffee</li>
      <li>Tea</li>
      <li>Milk</li>
    </ul>
  </p>
</div>

答案 1 :(得分:0)

尝试将padding: 0;添加到您的<ul>标签中。 看起来像这样:

<div class="col-md-4 mb-1">
  <i class="fas fa-hiking fa-4x"></i>
  <h4 class="my-4" font-weight-bold>What to bring</h4>
  <p>
    <ul style="list-style-type: none; padding: 0;">
      <li>Coffee</li>
      <li>Tea</li>
      <li>Milk</li>
    </ul>
  </p>
</div>