Hello,
I’m confused by the “Applied Visual Design: Create a More Complex Shape Using CSS and HTML” lesson - I thought the ::before and ::after pseudo-elements added content before and after the selected element, respectively.
But when I change the color and default the position of the ::before and ::after pseudo-elements (to make more apparent), along with adding the empty string for ::before, I see that the ::before and ::after elements are essentially (if not entirely) in the same position as the selected element itself (the “.heart” class).
I have no idea what to make of this. I’ve tried looking for answers regarding the logistics of the ::before and ::after pseudo-elements, but I can’t seem to find a satisfactory or relevant answer. Any help would be appreciated. Thanks!
<style>
.heart {
position: absolute;
margin: auto;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: pink;
height: 50px;
width: 50px;
transform: ;
}
.heart::after {
background-color: blue;
content: "";
border-radius: 25%;
position: absolute;
width: 50px;
height: 50px;
top: 0px;
left: 0px;
}
.heart::before {
content: "";
background-color: yellow;
border-radius: 50%;
position: absolute;
width: 50px;
height: 50px;
top: 0px;
left: 0px;
}
</style>
<div class = "heart"></div>