如何用bootstrap把<a>标签放在卡片的右上角?

how to put <a> tag at top right corner of card with bootstrap?

我有背景图片的卡片

  <div class="col-12 col-sm-8 col-md-6 col-lg-4 mt-4">
    <div class="card">

      <img class="card-img" style=" filter: brightness(75%);" src="{{$category->photo}}">
      <div class="card-img-overlay text-white d-flex flex-column justify-content-center">
        <a class="text-right"><i class="fas fa-pen"></i></a>
        <h1 class="card-title text-white text-center ">{{$category->name}}</h1>
      </div>
    </div>
  </div>

右上角有我想放的笔图标

试用位置实用程序 类。

https://getbootstrap.com/docs/5.1/utilities/position/

例如:

<div class="card position-relative">
  <!-- other elements -->
  <a class="text-right position-absolute top-0 end-0"><i class="fas fa-pen"></i></a>
</div>

详细了解 CSS 职位:https://developer.mozilla.org/en-US/docs/Web/CSS/position