2016-04-22 53 views
1

我想在中间的顶部中心对齐多个表格。在这些表格下面,我想要列出左对齐的垂直按钮。我尝试过许多不同的技术,但其中没有一种似乎可行。请有人可以帮忙吗?HTML中心对齐Div中的表格与下面的按钮列表

当前小提琴例:

https://jsfiddle.net/Jaron787/gg30jgh5/

CSS

.TSS { 
    font-family: Verdana, Geneva, sans-serif; 
    font-size: 10.6px; 
    font-style: normal; 
    text-decoration: none; 
    float: left; 
    padding-top: 10px; 
    padding-right: 10px; 
    padding-bottom: 10px; 
    padding-left: 10px; 
    border: 1px solid black; 
} 

.button { 
    background-color: #4CAF50; 
    /* Green */ 
    border: none; 
    color: white; 
    padding: 5px 15px; 
    text-align: center; 
    text-decoration: none; 
    display: inline-block; 
    font-size: 16px; 
    margin: 4px 2px; 
    -webkit-transition-duration: 0.4s; 
    /* Safari */ 
    transition-duration: 0.4s; 
    cursor: pointer; 
} 

.button1 { 
    background-color: white; 
    color: black; 
    border: 2px solid #4CAF50; 
} 

.button1:hover { 
    background-color: #4CAF50; 
    color: white; 
} 

HTML

<div id="lse" class="display"> 
    <table id="tblData" class="TSS"> 
    <tr> 
     <td align="center" colspan="4"><b>Table 1</b></td> 
    </tr> 
    </table> 

    <table id="tblData" class="TSS"> 
    <tr> 
     <td align="center" colspan="4"><b>Table 2</b></td> 
    </tr> 
    </table> 

    <input type="submit" class="button button1" name="submitButton" value="Button 1"> 
    <input type="submit" class="button button1" name="submitButton" value="Button 2"> 
    <input type="submit" class="button button1" name="submitButton" value="Button 3"> 
    <input type="submit" class="button button1" name="submitButton" value="Button 4"> 

</div> 

回答

2

可能只是在表格周围创建一个包装。

<div id="centertbl"> 
<table id="tblData" class="TSS"> 
    <tr> 
    <td align="center" colspan="4"><b>Table 1</b></td> 
    </tr> 
</table> 

<table id="tblData" class="TSS"> 
    <tr> 
    <td align="center" colspan="4"><b>Table 2</b></td> 
    </tr> 
</table> 

然后将文本对齐中心。

#centertbl { text-align: center;} 

这将使表中心居中。删除了类.TSS中的margin: 0 auto;

变化从display: inline-block;按钮的CSS代码display: block;

jsFiddle : https://jsfiddle.net/gg30jgh5/6/

+0

很好,谢谢! – Jaron787

1

我认为你需要这种类型的CSS:

对于这个div两个:

https://jsfiddle.net/gg30jgh5/9/

+0

谢谢,但我接下来要在顶部的中心彼此的表。然后在垂直按钮列表下方。更新了问题,因为它不清楚! – Jaron787

+0

请检查更新的提琴链接 – Jainam

+0

非常感谢!我只需要将按钮垂直排列在左下方 – Jaron787

0

设置一个div内表和设置保证金左:这个50%的div 将所有按钮的DIV中,明确设定。