可以用div flex容器包装。然后只对齐子容器。然后从子容器中移除文本对齐。
.container {
display: flex;
justify-content: center;
}
.center-screen {
display: flex;
flex-direction: column;
justify-content: center;
}
<div class="container">
<div class='center-screen'>
<label class='input2' for='pop'><b>Population proportion (p)</b></label>
<input class='input2' type='number' step='0.01' id='pop' value='0.43'/>
<label class='input2' for='samplesize'><b>Sample size (n)</b></label>
<input class='input2' type='number' id='samplesize' value='40'/>
<input class='input2' type='button' value='Calculate' />
</div>
</div>