将 FontAwesome 图标移到 li 之外

Move FontAwesome Icons OUTSIDE of li

我有一个我觉得应该很简单的问题,但它被证明是一个棘手的问题。

我只是有一个包含各种 <li> 元素的 <ul>。 分配给每个 LI 的是一个很棒的字体图标。

我的问题是我希望图标位于列表项的外部,此时它在列表项内部并推动第一行文本,我希望两行文本都内嵌在图标旁边。

我尝试使用以下方法:-

#skills-list li{
    list-style-position: outside;
}

这似乎只适用于子弹等标准标记。我也尝试过针对其他 类 例如:-

#skills-list li.i{...}

#skills-list li.a{...}

有人能帮忙吗,下面是我的代码:-

<ul id="skills-list">
  <li><i class="fas fa-check-square"></i> I aim to implement modern technologies into my projects using a movile first approach.</li>
  <li><i class="fas fa-check-square"></i> Exposing myself to GIT allows me to track, comment and update my project in a team repository.</li>
  <li><i class="fas fa-check-square"></i> Working with BOOTSTRAP frameworks allows implementation of elegant and modern design.</li>
  <li><i class="fas fa-check-square"></i> Learning SASS allowed me to speed up my web design process, creating fast and efficient CSS3.</li>
  <li><i class="fas fa-check-square"></i> Basic Understanding of JavaScript and JQuery means that I understand the process of DOM Manipulation.</li>
  <li><i class="fas fa-check-square"></i> My previous background is in Animation, providing me with a good eye for detail and creativity.</li>
</ul>
      <ul id="skills-list">
        <i class="fas fa-check-square"></i><li> I aim to implement modern technologies into my projects using a movile first approach.</li>
      </ul>

这就是你想要的吗?

使用绝对定位。

ul {
  list-style: none;
}

#skills-list li {
  position: relative;
}

#skills-list li i {
  position: absolute;
  left: -2em
}
<link href="https://use.fontawesome.com/releases/v5.0.7/css/all.css" rel="stylesheet" />
<ul id="skills-list">
  <li><i class="fas fa-check-square"></i> I aim to implement modern technologies into my projects using a movile first approach.</li>
  <li><i class="fas fa-check-square"></i> Exposing myself to GIT allows me to track, comment and update my project in a team repository.</li>
  <li><i class="fas fa-check-square"></i> Working with BOOTSTRAP frameworks allows implementation of elegant and modern design.</li>
  <li><i class="fas fa-check-square"></i> Learning SASS allowed me to speed up my web design process, creating fast and efficient CSS3.</li>
  <li><i class="fas fa-check-square"></i> Basic Understanding of JavaScript and JQuery means that I understand the process of DOM Manipulation.</li>
  <li><i class="fas fa-check-square"></i> My previous background is in Animation, providing me with a good eye for detail and creativity.</li>
</ul>

您可以尝试使用 position: absolute;

将图标 () 定位在相应的列表项之外

我不知道你想要达到的实际视觉效果,但它应该是这样的:

li {
  position: relative;
}

i {
  position absolute;
  left: -24px;
  top: 0;
}

只需使用 bootstraps 排版将列表标记为无样式 类

<ul id="skills-list" class="list-unstyled">

运行要查看的片段:

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">

<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.13/css/all.css" integrity="sha384-DNOHZ68U8hZfKXOrtjWvjxusGo9WQnrNx2sqG0tfsghAvtVlRW3tvkXWZh58N9jp" crossorigin="anonymous">


<ul id="skills-list" class="list-unstyled">
  <li><i class="fas fa-check-square"></i> I aim to implement modern technologies into my projects using a movile first approach.</li>
  <li><i class="fas fa-check-square"></i> Exposing myself to GIT allows me to track, comment and update my project in a team repository.</li>
  <li><i class="fas fa-check-square"></i> Working with BOOTSTRAP frameworks allows implementation of elegant and modern design.</li>
  <li><i class="fas fa-check-square"></i> Learning SASS allowed me to speed up my web design process, creating fast and efficient CSS3.</li>
  <li><i class="fas fa-check-square"></i> Basic Understanding of JavaScript and JQuery means that I understand the process of DOM Manipulation.</li>
  <li><i class="fas fa-check-square"></i> My previous background is in Animation, providing me with a good eye for detail and creativity.</li>
</ul>