Overflow need to be applied to the container where the element are overflowing and not the element itself and you will not have any overflow because min-content
doesn't mean the minimum height from all the elements. This property is useful when dealing with width and not height because height are by default auto
and already fitting the minimum content in most of the cases.
What you need is to simply set a max-height
or height
to the container:
.first {
height: 50px;
background-color: red;
}
.second {
height: 100px;
background-color: green;
}
.container {
display: grid;
max-height:50px;
overflow:hidden;
grid-template-columns: 265px auto;
}
<div class="container">
<div class="first"></div>
<div class="second"></div>
</div>
or grid-template-rows
.first {
height: 50px;
background-color: red;
}
.second {
height: 100px;
background-color: green;
}
.container {
display: grid;
grid-template-rows:50px;
overflow:hidden;
grid-template-columns: 265px auto;
}
<div class="container">
<div class="first"></div>
<div class="second"></div>
</div>
UPDATE
In case you don't want to set a height to the container you can make the content of the second column to be out of the flow thus it won't increase the height of the container:
.first {
height: 50px;
background-color: red;
}
.second {
position:relative;
}
.second > div {
height: 100px;
background-color: green;
position:absolute;
top:0;
left:0;
right:0;
}
.container {
display: grid;
overflow:hidden;
grid-template-columns: 265px auto;
}
<div class="container">
<div class="first"></div>
<div class="second">
<div></div>
</div>
</div>