You need to add box-sizing: border-box
to your .input-box
class:
See the documentation here for some visual examples: https://developer.mozilla.org/en-US/docs/Web/CSS/box-sizing
<!DOCTYPE html>
<html>
<head>
<title>
Practice
</title>
<style>
.parent{
display: flex;
flex-direction: row;
}
.child-1{
flex: 1;
}
.input-box{
width: 100%;
box-sizing: border-box;
}
.child-2{
width: 100px;
}
</style>
</head>
<body>
<div class="parent">
<div class="child-1">
<input class="input-box" placeholder="Search">
</div>
<div class="child-2">
<button style="opacity: 0.8;">Click me</button>
</div>
</div>
</body>
</html>