<div class="am-form-group" style="width: 300px"> <input type="text" name="verify" placeholder="验证码"> <a href="javascript:void(0);" rel="external nofollow" title="点击更换验证码"> <img style="margin-top: 12px;height: 100px;float:right" id="imgVerify" src="/getVerify" alt="更换验证码" height="36" width="100%" onclick="getVerify(this);"> </a> </div>
我猜 你想要的答案是这个 自动居中,有用麻烦点采纳 蟹蟹
<div class="am-form-group" style="width: 300px;display: flex;margin: 0 auto;">
<input type="text" name="verify" placeholder="验证码">
<a href="javascript:void(0);" rel="external nofollow" title="点击更换验证码" style="
margin-left: 15px;">
<img style="float:right;" id="imgVerify"
src="微信图片_20200718130402.jpg" alt="更换验证码" height="36" width="100%" onclick="getVerify(this);">
</a>
</div>
以下三种都可以不换行
1.<div class="div1">123</div>
<div class="div2">456</div>
<style>
.div1 {
float: left;
}
.div2 {
float: left;
}
</style>
2.<div class="div1">123</div>
<div class="div2">456</div>
<style>
.div1 {
display: inline-block;
}
.div2 {
display: inline-block;
}
</style>
3.<div class="parent">
<div class="div1">123</div>
<div class="div2">456</div>
</div>
<style>
.parent {
display: flex;
}
</style>
牛
试试这个:https://blog.csdn.net/qq_42415827/article/details/114634849
直接给父元素display:inline-block;