我正在输入中放置一个带有图标的按钮,请参见此处: 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;
}
如何在输入内部用red outline
使按钮与green outline
垂直对齐?
从上面显示的尝试来看,实现所需输出所缺少的是什么?
答案 0 :(得分:-2)
pls试试这个CSS
<style>
form {
display: flex;
align-items: center;
}
</style>