Html 如何在表格下方居中对齐按钮?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1036798/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to align button centered below table?
提问by Sam Kong
I put form elements in a table so that column names and inputs are aligned to 2-columns. And I put submit button and cancel button below the table. The table width is not fixed. I want to put the buttons center-aligned of the table width.
我将表单元素放在一个表中,以便列名和输入对齐到 2 列。我把提交按钮和取消按钮放在桌子下面。表格宽度不固定。我想将按钮与表格宽度居中对齐。
One simple way is to put the buttons in the table. But I want to separate them from the table. What's the most elegant way to do that?
一种简单的方法是将按钮放在表格中。但我想把它们从桌子上分开。什么是最优雅的方式来做到这一点?
回答by Dimi Takis
Structure like this:
结构如下:
<div>
<!-- Your table -->
<table />
<!-- Your buttons -->
<div style="text-align:center;">
<input />
</div>
</div>
回答by Steve
Since the buttons and table are related you could use a fieldset:
由于按钮和表格是相关的,您可以使用字段集:
<fieldset>
<!-- Your table -->
<table />
<!-- Your buttons -->
<p style="text-align:center;">
<input />
</p>
</fieldset>