将按钮和文本放在同一行,文本位于按钮中心
Give Button and Text on the same line and text to be center of button
<input type="button" class="click" id="click" value="Click" style="width: 45px; margin-top: 1.5%; height: 20px; text-align: center; color: white; background: #23b7e5; font-size: 13px; border-color: #23b7e5; border-radius:2px; padding: 0px; ">
<label class="control-label" style="border: thin red solid; margin-top: 10px;">Here to find location</label>
我希望按钮和文本框位于我得到的同一行,但我没有让文本位于按钮的中心。我得到这个输出。我希望 "Here to find location" 成为按钮的中心。
谢谢。
任何帮助将不胜感激。
尝试一次
<button>Click</button><input type="text" value =" Here The Location"/>
display: inline-block
和 vertical-align:middle
就可以了。
input, label{
display: inline-block;
vertical-align: middle;
margin: 10px 0;
}
<input type="button" class="click" id="click" value="Click" style="width: 45px; height: 20px; text-align: center; color: white; background: #23b7e5; font-size: 13px; border-color: #23b7e5; border-radius:2px; padding: 0px; ">
<label class="control-label" style="border: thin red solid;">Here to find location</label>
你给了margin-top:1.5%;输入和 margin-top:10px 标签,你应该为两者使用相同的边距值
input{
float:left;
width: 45px;
margin-top:10px;
height: 20px;
text-align: center;
color: white;
background: #23b7e5;
font-size: 13px;
border-color: #23b7e5;
border-radius:2px;
padding: 0px;
}
.control-label{
float:left;
border: thin red solid;
margin-top: 10px;
}
<input type="button" class="click" id="click" value="Click" style="">
<label class="control-label" style="">Here to find location</label>
<input type="button" class="click" id="click" value="Click" style="width: 45px; margin-top: 1.5%; height: 20px; text-align: center; color: white; background: #23b7e5; font-size: 13px; border-color: #23b7e5; border-radius:2px; padding: 0px; ">
<label class="control-label" style="border: thin red solid; margin-top: 10px;">Here to find location</label>
我希望按钮和文本框位于我得到的同一行,但我没有让文本位于按钮的中心。我得到这个输出。我希望 "Here to find location" 成为按钮的中心。
谢谢。 任何帮助将不胜感激。
尝试一次
<button>Click</button><input type="text" value =" Here The Location"/>
display: inline-block
和 vertical-align:middle
就可以了。
input, label{
display: inline-block;
vertical-align: middle;
margin: 10px 0;
}
<input type="button" class="click" id="click" value="Click" style="width: 45px; height: 20px; text-align: center; color: white; background: #23b7e5; font-size: 13px; border-color: #23b7e5; border-radius:2px; padding: 0px; ">
<label class="control-label" style="border: thin red solid;">Here to find location</label>
你给了margin-top:1.5%;输入和 margin-top:10px 标签,你应该为两者使用相同的边距值
input{
float:left;
width: 45px;
margin-top:10px;
height: 20px;
text-align: center;
color: white;
background: #23b7e5;
font-size: 13px;
border-color: #23b7e5;
border-radius:2px;
padding: 0px;
}
.control-label{
float:left;
border: thin red solid;
margin-top: 10px;
}
<input type="button" class="click" id="click" value="Click" style="">
<label class="control-label" style="">Here to find location</label>