我在输入中放置了一个带有图标的按钮,请参见此处: fiddle
<form>
<input type="text">
<button type="submit"><i class="fa fa-search"></i></button>
</form>
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
form {
width: 400px;
}
input {
background-color: white;
border: 1px solid green;
display: inline-block;
font-size: 18px;
line-height: 1;
margin: 0;
margin-right: -48px;
padding: 12px;
}
button {
background-color: white;
border: 1px solid red;
cursor: pointer;
display: inline-block;
font-size: 28px;
line-height: 1;
margin: 0;
outline: 0;
}
i {
display: block;
line-height: 1;
margin: 0;
padding: 0;
}
如何将按钮与 红色轮廓
垂直对齐,在输入框内与 绿色轮廓
垂直对齐?
从我上面显示的尝试来看,实现所需输出缺少什么?
最佳答案
请试试这个CSS
<style>
form {
display: flex;
align-items: center;
}
</style>
关于html - 输入中的垂直对齐按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53603142/