Let's say I have something like this:
.test-container {
margin-left: 100px;
margin-top: 40px;
}
.test-container::after {
content: "";
position: absolute;
height: 2px;
background-color: red;
left: 0;
right: 0;
}
<div class="test-container">
<h1>TESTE</h1>
<h2>TESTE</h2>
<img src="https://www.acmetek.com/wp-content/uploads/rapidssl-logo.png" />
</div>
As can be seen ::after
is positioned before the image and not as the last element of the div, but if I have only text inside the div ::after
is indeed positioned as the last element.
I understand that I could position after
with bottom
and also understand that I can't insert pseudo-selectors to image tags, but here I am using a div
and I don't get this behavior.
What I'd like to know is why it behaves like that.