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

Time:11-22

I have card which has image in background

  <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>

There is pen icon which I want to put on top right corner

enter image description here

CodePudding user response:

Try out the position utility classes.

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

For example:

<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>

Learn more about CSS position: https://developer.mozilla.org/en-US/docs/Web/CSS/position

  • Related