html - 改变 <tr> 中控件相对于其他控件的位置

标签 html css asp.net

我得到了这个图形用户界面:

enter image description here

但我想要这个:

enter image description here

图片nr1的代码:

<tr>
    <td colspan ="3">
        <asp:ListBox ID="tr_process_list" runat="server" Rows="10" style="width:180px;" OnInit="tr_process_list_Init" SelectionMode="Multiple">
        </asp:ListBox>
        <asp:Button runat="server" ID="addProcess" Text="Add" OnClick="addProcess_Click"/>
        <asp:Button runat="server" ID="removeProcess" Text="Remove" OnClick="removeProcess_Click" />
        <asp:ListBox ID="tr_process_selectedlist" runat="server" Rows="10" style="width:180px;" OnInit="tr_process_selectedlist_Init" OnSelectedIndexChanged="tr_process_selectedlist_SelectedIndexChanged" AutoPostBack="true">
        </asp:ListBox>
     </td>
</tr>

这怎么可能?

最佳答案

如果您可以修改 HTML,请在按钮周围添加一个包装元素并尝试使用以下 CSS。

诀窍是添加一个包装元素,它是一个内联 block 。在 inline-block 中,您可以在按钮上使用 display: block,并使用 margin left/right auto 将它们居中。

您可以根据需要指定宽度或填充来设置空白的样式。

如果您的 textarea 元素足够高,您可以通过为两个 textarea 元素指定 vertical-align: middle 使标签垂直居中和 .inline-panel 元素。

/* Example for large text area panels */
td { 
  border: 1px dotted gray;
}
td textarea {
  height: 200px; /* for example */
  vertical-align: middle;
}

.inline-panel {
  border: 1px dotted blue;
  display: inline-block;
  vertical-align: middle;
  text-align: center;
  width: 8em; /* optional */
  padding-bottom: 0em; /* optional */
}
.inline-panel button {
  display: block;
  margin: 10px auto; /*left right values of auto for centering */
}
<table>
  <tr>
    <td>
      <textarea></textarea>
      <div class="inline-panel">
        <button>View</button>
        <button>Reset</button>
      </div>
      <textarea></textarea>
    </td>
  </tr>
</table>

关于html - 改变 <tr> 中控件相对于其他控件的位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28091351/

相关文章:

javascript - 编辑本地存储用户?

javascript - 捕获最大化的视口(viewport)宽度

html - 顶边距不起作用反而高度增加

css - 如何使 CSS 网格左列适合行数

javascript - 如何修复 javascript 实时语法突出显示中的反向文本?

javascript - ng-repeat,数据更新后不更新表吗?

css - 在 Netbeans 8.2 中解析 Bootstrap 4 时出错

c# - 扩展成员(member)提供者

asp.net - 如何使应用程序池崩溃?

c# - ASP.NET 无法更改 Formview 控件的可见性