by default min-width
will take inside element width
.container {
width: 200px;
background: red;
height: 50px;
}
.child1 {
background: black;
display: inline-block;
}
.child2 {
background: blue;
display: inline-block;
width: auto;
min-width: 0px; /*changed width to min-width */
float: right;
-webkit-transition: 2s;
transition: 2s;
}
.child2:hover {
min-width: 100px; /* changed from width to min-width */
}