The parent node "container" has height ,margin can be calculated,Why "item" css margin-top and margin-bottom has no effect?
body,html {
margin: 0;
padding: 0;
}
.container {
height: 400px;
margin: 10px 50px;
border-radius: 10px;
background-color: lightgrey;
overflow: hidden;
}
.item {
box-sizing: border-box;
width: 50px;
height: 50px;
background-color: green;
margin-left: auto;
margin-right: auto;
margin-top: auto;
margin-bottom: auto;
}
<body>
<div class="container">
<div class="item"></div>
</div>
</body>
