HTML/CSS - 按钮在另一个元素下排列

标签 html css

这就是我现在的表格- https://imgur.com/a/nFx2lyA

有没有办法将按钮“推”到右边?我希望我的“-”按钮位于下拉列表中的向下箭头下方。

这是我想要的示例(它使用文本框,但应该是下拉菜单。显示“对齐方式不正确”的按钮是我希望“-”按钮所在的位置)。 Codepen

HTML代码:

.button6 {
  right: 200px;
  width: 30px;
  padding: 8px 10px;
  text-align: right;
  font-size: 60%;
  margin-left: 15px;
  border-radius: 5px;
  margin-bottom: 5px;
  margin-top: 5px;
  white-space: pre;
}

.btns {
  text-align: right;
}

.input,
.select {
  margin-left: 10px;
  width: 100%;
  margin-bottom: 5px;
}
<label for="services1">Service 1:</label> </td>
<td width="50%">
  <select name="services1" id="services1" v-model="services1">
  </select>
</td>
</tr>
</table>
<div class="btns">


  <button type="button" class="button6" id="add_service">+</button>
  <button type="button" class="button6" id="delete_row">-</button>

</div>

最佳答案

尝试 float 属性,连同 margin: 0 on body

 
body {
  margin: 0;
}
.button6 {

right: 200px;   
width:30px;
padding: 8px 10px;
text-align: right;
font-size: 60%;
margin-left : 15px;
border-radius: 5px;
margin-bottom:5px;
margin-top:5px;
white-space: pre; 

}
.btns {
  text-align: right;
}
.input,.select {
  margin-left: 10px;
  width: 100%;
  margin-bottom:5px;
}
<div style="float:right;">
  <label for="services1">Service 1:</label>
  <select name="services1" id="services1" v-model="services1">
</div>
                    </select>
<div class="btns">
<button type="button" class="button6" id="add_service">+</button> 
<button type="button" class="button6" id="delete_row">-</button>
</div>

关于HTML/CSS - 按钮在另一个元素下排列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50686055/

相关文章:

html - 如何禁止 firefox 密码字段完成?

php - 使用特定的 CSS 加载 HTML 文件

javascript - 使用 CSS 高度 : 0; 在 JS 或 jQuery 中获取元素高度

javascript - 如何使用javascript控制标签当前效果

html - 为什么我的 div 不能全部水平对齐?

javascript - 从文本区域清除换行符

html - 为什么我使用相同的十六进制值在不同的浏览器中得到不同的颜色?

css - 如何为 css 中的某些类创建不同且唯一的 ID?

javascript - 在javascript中计算上一个结束日期和下一个开始日期之间的差距

html - 显示 Accordion 内容