在列表组项目操作内容的右侧添加箭头

时间:2019-01-07 23:11:06

标签: bootstrap-4

我正在尝试在以list-group-item-action类为目标的列表组中显示的内容的右侧添加FontAwesome图标。我可以使箭头位于内容的右侧,但不能使其垂直居中。

有没有一种方法可以仅使用CSS

.list-group .list-group-item-action {
  position: relative;
  display: block; }
  .list-group .list-group-item-action:before {
    font-size: 2rem;
    font-weight: 900;
    content: '\f105';
    right: 15px;
    position: absolute;
    display: inline-block;
    font-style: normal;
    font-family: "Font Awesome 5 Pro";
    font-variant: normal;
    text-rendering: auto;
    transition: all 1s ease; }
    
  .list-group .list-group-item-action:hover:before {
    right: 5px; }
<!doctype html>
<html lang="en">

<head>
  <!-- Required meta tags -->
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

  <!-- Bootstrap CSS -->
  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">

  <title>Hello, world!</title>
</head>

<body>
  <div class="list-group">
    <a href="#" class="list-group-item list-group-item-action">
    Cras justo odio
  </a>
    <a href="#" class="list-group-item list-group-item-action">
    <h2>Dapibus ac facilisis</h2>
    <p>Vestibulum at eros</p></a>
    <a href="#" class="list-group-item list-group-item-action">Morbi leo risus</a>
    <a href="#" class="list-group-item list-group-item-action">Porta ac consectetur ac</a>
    <a href="#" class="list-group-item list-group-item-action disabled" tabindex="-1" aria-disabled="true">Vestibulum at eros</a>
  </div>

  <!-- Optional JavaScript -->
  <!-- jQuery first, then Popper.js, then Bootstrap JS -->
  <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js" integrity="sha384-wHAiFfRlMFy6i5SRaxvfOCifBUQy1xHdJ/yoi7FRNXMRBu5WHdZYu1hA6ZOblgut" crossorigin="anonymous"></script>
  <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js" integrity="sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k" crossorigin="anonymous"></script>
</body>

</html>

0 个答案:

没有答案