While the pseudo class is sliding out we can see that its left corners overlap the initial border of element. I wonder how I can fix this?
.item {
width: 400px;
height 100px;
border: 2px solid black;
border-radius: 15px;
position: relative;
}
.item::before {
content: "";
left: 0;
top: 0;
border-radius: 15px;
position: absolute;
background: red;
width: 100%;
height: 100%;
z-index: -1;
transform: scaleX(0);
transform-origin: left;
transition: all 3s;
}
.item:hover::before {
transform: scaleX(1);
}
<div style="display: flex; justify-content: center;">
<div class="item">
<p>
Lorem ipsum, dolor sit amet consectetur adipisicing elit. Accusantium dolorum aliquam dolor nisi quaerat cum?
</p>
</div>
</div>
UPD: Also I have noticed that when the transition completes there are small gaps between pseudo class and the border of element. Any ideas on this?
2
Answers
To fix the issue where the left corners of the pseudo class overlap the initial border of the element.
Just use border-box instead