我正在尝试将texbox转到按钮,但我的情况是第一行texbox然后下一行按钮 HTML: -
<div class="styled-input" id="surnamediv">
<input type="text" id="surName" /><button id="add" class="hidden">Add</button>
<label>Surname</label>
<span></span>
</div>
CSS: -
.custom-input #surnamediv #add{
vertical-align:middle;
}
答案 0 :(得分:2)
尝试这些风格
#surnamediv {
display: flex;
align-items: center;
}
#surnamediv label {
margin-left: 10px;
}
#surnamediv {
display: flex;
align-items: center;
}
#surnamediv label {
margin-left: 10px;
}
&#13;
<div class="styled-input" id="surnamediv">
<input type="text" id="surName" /><button id="add" class="hidden">Add</button>
<label>Surname</label>
<span></span>
</div>
&#13;
答案 1 :(得分:0)
使用flex进行垂直对齐
<style>
.styled-input {
width:100℅;
display:flex;
align-items:center;
}
</style>
答案 2 :(得分:0)
#surnamediv {
display: table;
}
#surnamediv input, #surnamediv button, #surnamediv label {
display: table-cell;
vertical-align: middle;
}
#surnamediv label {
padding-left: 10px;
}
&#13;
<div class="styled-input" id="surnamediv">
<input type="text" id="surName" /><button id="add" class="hidden">Add</button>
<label>Surname</label>
<span></span>
</div>
&#13;