I've read about the position property and its values but didn't understand position absolute's behavior on its element (practically).
Below are the two images in which .bottom cloud and .mountain are given position absolute property in the respective below images.
HTML and CSS codes are given at the end
But the behavior is different:-
1.).bottom-cloud goes up(above) the mountain image i.e, still inside the conainer-1
2.).mountain not only went away its previous position but also went outside the container-1
HTML:-
<body>
<div class="container">
<div class="content-1">
<img class="top-cloud" src="images/cloud.png" alt="Clouds">
<div class="header-2">
<h1>I'm Pradeep Gaur</h1>
<p>A Computer Science Geek</p>
</div>
<img class="bottom-cloud" src="images/cloud.png" alt="clouds">
<img class="mountain" src="images/mountain.png" alt="Mountain">
</div>
<div class="content-2">
</div>
<div class="content-3">
</div>
</div>
</body>
CSS:-
body{
margin:0px;
padding:0px;
text-align: center ;
}
.content-1{
background-color: rgb(198, 243, 228);
}
.bottom-cloud{
position:absolute;
}
.mountain{
/* position:absolute; */
}
.content-2, .content-3{
width:200px;
height:200px;
}
.content-2{
background-color: red;
}
.content-3{
background-color: yellow;
}