Home > database >  How to remove border for font awesome icon inside anchor tag
How to remove border for font awesome icon inside anchor tag

Time:07-19

We are using border-bottom property to add border for the anchor tag and adding font awesome icon along with the anchor tag.

<a href="google.com" >
  "Test data"
  ::after
</a>

CSS :-

a.link {
  border-bottom: 1px solid black;

  &::after {
    font-family: 'Font Awesome 5 Pro';
    content: '\f08e';
    font-size: 14px;
  }
}

It is adding the border under font awesome icon as well. We would like to remove border for font awesome icon in anchor tag.

Is it possible ?

CodePudding user response:

If you can't change your html, then you could move your icon outside your anchor using absolute positioning

.test {
  border-bottom: 1px solid black;
  position: relative;
  margin-right: 1.5em; /* needs enough margin so the icon can sit there */
}

.test::after {
  content: 'a';
  display: inline-block;
  position: absolute;
  left: 100%;
  padding-left:0.5em;
}
<a  href="#">some text</a> some other text

  • Related