CSS Flex 布局实现两个按钮居中对齐
<div class='call-to-action-area gray-bg ptb-60'>
<div class='container'>
<div class='form-group'>
<label></label>
<textarea class='form-control' id='chat-gpt-input' placeholder='输入问题' rows='3' resize='none' style='width: 100%; margin: 0 auto; background-color: #f4f4f4; color: #333; border: 1px solid #ccc; border-radius: 12px;'></textarea>
</div>
<div class='call-to-action'>
<a onclick='callCHATGPT()' class='btn btn-large' href='#' style='background-color: #4cae4c; color: #fff; font-weight: bold; border-radius: 5px; padding: 10px 20px; border: none; box-shadow: none; text-decoration:none;' onmousedown='this.style.backgroundColor='#3c903c'' onmouseup='this.style.backgroundColor='#4cae4c''>回答</a>
<a onclick='clearTextArea()' class='btn btn-large' href='#' style='background-color: #d9534f; color: #fff; font-weight: bold; border-radius: 5px; padding: 10px 20px; border: none; box-shadow: none; text-decoration:none; margin-left: 20px;' onmousedown='this.style.backgroundColor='#c9302c'' onmouseup='this.style.backgroundColor='#d9534f''>清空</a>
</div>
<div class='form-group'>
<label></label>
<textarea class='form-control' id='chatgpt-response' placeholder='长途访问,请耐心等待回答 Ai生成它很快,但是由于网络问题我们需要等待,通常内容越长等待越久 如果长时间没反应请刷新页面重试' rows='26' resize='none' style='width: 100%;height: auto; margin: 0 auto; background-color: #f4f4f4; color: #333; border: 1px solid #ccc; border-radius: 10px; overflow: scroll;'></textarea>
</div>
</div>
<div class='call-to-action'>
<style>
.call-to-action {
display: flex;
justify-content: center;
align-items: center;
margin-top: 20px;
}
<pre><code> .btn {
margin: 0 10px;
}
</style>
</div>
</code></pre>
</div>
<p>可以使用flex布局来实现两个按钮居中的效果,具体代码如下:</p>
<p>通过设置display为flex,让按钮组成为一个弹性盒子,通过设置justify-content和align-items为center,让按钮在水平和垂直方向上都居中对齐。最后,通过设置.btn的margin来调整两个按钮之间的距离。</p>
原文地址: https://www.cveoy.top/t/topic/mmVz 著作权归作者所有。请勿转载和采集!