.parent{
background: #64B5F6;
height: 100vh;
display: grid;
grid-template-columns: 40% 60%;
}
.child1 {
background: #42A5F5;
height: 100%;
}
.child2{
background: #FFEB3B;
height: 100%;
}
.img1 {
width: 100%;
height: 100%;
object-fit: cover;
}
.img2 {
width: 100%;
height: 100%;
object-fit: cover;
}
<div class='parent'>
<div class='child1'>
<img class='img1'src="https://images.unsplash.com/photo-1597594879431-8aecf7c2dd49?ixlib=rb-1.2.1&q=85&fm=jpg&crop=entropy&cs=srgb&ixid=eyJhcHBfaWQiOjE0NTg5fQ" alt="man image">
</div>
<div class='child2'>
<img class='img2'src="https://images.unsplash.com/photo-1598505628759-67b9346af31c?ixlib=rb-1.2.1&q=85&fm=jpg&crop=entropy&cs=srgb&ixid=eyJhcHBfaWQiOjE0NTg5fQ" alt="man image">
</div>
</div>
In the above code I have set parent's height
to be 100vh
. Which means it should be contained in the viewport's height. But its child elements are extending this height. I ran this inside codepen.io and saw that parent now is not of height
of viewport but more than that. I don't know what I am doing wrong here.