在CSS中,我们可以使用“display: inline-block”样式将两个按钮放在同一行中。
.btn {
display: inline-block;
padding: 10px 20px;
background-color: #f0f0f0;
border: none;
border-radius: 5px;
font-size: 16px;
color: #333;
text-align: center;
text-decoration: none;
cursor: pointer;
margin-right: 10px; /*调整按钮之间的间距*/
} 然后我们可以在HTML中创建两个按钮元素,并应用这个CSS样式:
<button class="btn">按钮1</button>
<button class="btn">按钮2</button> 这样,两个按钮就会并排在同一行中了。