Home > Blockchain >  Remove background outline on the side of the border after skew transform
Remove background outline on the side of the border after skew transform

Time:03-19

Here is my markup:

<div >
   <p>Very Funny</p>
</div>

Here is my CSS:

div.labels p {
  background: red;
  border-left: 2rem solid white;
  border-right: 2rem solid white;
  color: white;
  font-family: 'Bebas Neue';
  text-transform: uppercase;
  line-height: 0.8;
  transition: 0.4s ease all;
  font-size: 4rem;
  -webkit-text-stroke: 2px white;
  letter-spacing: 2px;
  width: fit-content;
  padding: 1rem 2rem;
  transform: skew(-10deg);
}

Here is the demo: https://jsfiddle.net/90vLp4ub/

You will notice that there is a thin red line around the element due to the background. How can I get rid of that?

Thanks.

CodePudding user response:

To remove the red outlines and keep the animation, you can do this:

  1. Remove the borders left and right from p:hover
  2. Add some margin-left

div.labels p:hover {
  background: red !important;
  margin-left: 30px;
}
div.labels p {
  color: white;
  font-family: 'Bebas Neue';
  text-transform: uppercase;
  line-height: 0.8;
  transition: 0.4s ease all;
  font-size: 4rem;
  -webkit-text-stroke: 2px white;
  letter-spacing: 2px;
  width: fit-content;
  padding: 1rem 2rem;
  transform: skew(-10deg);
}
<div >
   <p>Very Funny</p>
</div>

CodePudding user response:

Just remove that left and right margins as solid. They are responsible for those red outlines

div.labels p:hover {
      background: red !important;
      border-left: 2rem;
      border-right: 2rem;
    }
    div.labels p {
      color: white;
      font-family: 'Bebas Neue';
      text-transform: uppercase;
      line-height: 0.8;
      transition: 0.4s ease all;
      font-size: 4rem;
      margin: 0 auto;
      letter-spacing: 2px;
      width: fit-content;
      padding: 1rem 2rem;
      transform: skew(-10deg);
    }
<div >
   <p>Very Funny</p>
</div>
    

  • Related