Add this:
* {
box-sizing:border-box;
}
It's because the input/button has padding and border added by the browser so the total ends up > 100%.
What the code above does is tell all elements to include padding and border into the width value.
You will also be suffering from a white-spacing issue. Basically because your elements are on a separate line, it adds white space in-between. To combat this you can either put them on the same line with no space or comment the area in-between, like so:
* {
box-sizing: border-box;
margin: 0px;
}
input {
width: 70%;
border: 3px solid;
}
button {
width: 30%;
}
<div>
<input type="text"><!--
--><button>Button</button>
</div>
Setting the div
element to have font-size: 0px;
would also work to remove the white-space, as long as you're not affecting the relative font-size of any child elements by doing so.