如何定位 SVG?

How do I position an SVG?

我在导航栏中有一个 SVG,悬停时应该向右移动。 HTML 和 CSS 如下:

.logo {
  font-weight: bold;
  text-transform: uppercase;
  margin-bottom: 1rem;
  text-align: center;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  font-size: 1.5rem;
  letter-spacing: 0.3ch;
  width: 100%;
}

.logo svg {
  display: flex;
  align-items: center;
  justify-content: center;
  transform: rotate(0deg);
  transition: var(--transition-speed);
}

.logo-text {
  display: inline;
  position: absolute;
  left: 1rem;
  transition: var(--transition-speed);
}

.navbar .logo-text {
  display: none;
}

.navbar:hover .logo svg {
  transform: rotate(-180deg);
}
<li class="logo">
  <a href="#" class="nav-link">
    <span class="link-text logo-text">ELC</span>
    <svg aria-hidden="true" focusable="false" data-prefix="fad" data-icon="angle-double-right" height="50" width="50" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" class="svg-inline--fa fa-angle-double-right fa-w-14 fa-5x">
            <g class="fa-group">
              <path
                fill="currentColor"
                d="M224 273L88.37 409a23.78 23.78 0 0 1-33.8 0L32 386.36a23.94 23.94 0 0 1 0-33.89l96.13-96.37L32 159.73a23.94 23.94 0 0 1 0-33.89l22.44-22.79a23.78 23.78 0 0 1 33.8 0L223.88 239a23.94 23.94 0 0 1 .1 34z"
                class="fa-secondary"
              ></path>
              <path
                fill="currentColor"
                d="M415.89 273L280.34 409a23.77 23.77 0 0 1-33.79 0L224 386.26a23.94 23.94 0 0 1 0-33.89L320.11 256l-96-96.47a23.94 23.94 0 0 1 0-33.89l22.52-22.59a23.77 23.77 0 0 1 33.79 0L416 239a24 24 0 0 1-.11 34z"
                class="fa-primary"
              ></path>
            </g>
          </svg>
  </a>
</li>

悬停时不是向右移动,而是向左移动,如下所示:

我希望箭头指向黑色 space 的最右侧,但它却指向左侧并覆盖了文本。我该如何更改?

为此,我在 <a> 元素上使用了 display-flexjustify-content: space-between

我也注释掉了.logo-text的绝对定位。

我还在 .logo 中添加了 list-style-type: none; 以删除要点。

.logo {
  font-weight: bold;
  text-transform: uppercase;
  margin-bottom: 1rem;
  text-align: center;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  font-size: 1.5rem;
  letter-spacing: 0.3ch;
  width: 100%;
  list-style-type: none;
}

.logo svg {
  align-items: center;
  justify-content: center;
  transform: rotate(0deg);
  transition: var(--transition-speed);
}

.logo-text {
  /* display: inline;
  position: absolute;
  left: 1rem; */
  padding-left: 1rem;                     /* added to shift text right */
  transition: var(--transition-speed);
}

.navbar .logo-text {
  display: none;
}

.navbar:hover .logo svg {
  transform: rotate(-180deg);
}

a {                                  /* added */
  display: flex;                     /* added */
  justify-content: space-between;    /* added */
}                                    /* added */
<li class="logo">
  <a href="#" class="nav-link">
    <span class="link-text logo-text">ELC</span>
    <svg aria-hidden="true" focusable="false" data-prefix="fad" data-icon="angle-double-right" height="50" width="50" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" class="svg-inline--fa fa-angle-double-right fa-w-14 fa-5x">
            <g class="fa-group">
              <path
                fill="currentColor"
                d="M224 273L88.37 409a23.78 23.78 0 0 1-33.8 0L32 386.36a23.94 23.94 0 0 1 0-33.89l96.13-96.37L32 159.73a23.94 23.94 0 0 1 0-33.89l22.44-22.79a23.78 23.78 0 0 1 33.8 0L223.88 239a23.94 23.94 0 0 1 .1 34z"
                class="fa-secondary"
              ></path>
              <path
                fill="currentColor"
                d="M415.89 273L280.34 409a23.77 23.77 0 0 1-33.79 0L224 386.26a23.94 23.94 0 0 1 0-33.89L320.11 256l-96-96.47a23.94 23.94 0 0 1 0-33.89l22.52-22.59a23.77 23.77 0 0 1 33.79 0L416 239a24 24 0 0 1-.11 34z"
                class="fa-primary"
              ></path>
            </g>
          </svg>
  </a>
</li>