首页 > Web开发 > 详细

<HTML>在一个表格内嵌套另一个表格时,如何居中?

时间:2019-09-05 09:37:08      阅读:91      评论:0      收藏:0      [点我收藏+]

在一个表格内嵌套另一个表格时,如何居中?

假设大表格为:

<table id="tableRow">
  <tr>
    <th>City</th>
    <th>Date</th>
    <th>Temperature</th>
    <th>Altitude</th>
    <th>Population</th>
    <th>Diner Rating</th>
  </tr>
  <tr>
    <td>Walla Walla, WA</td>
    <td class="center">June 15th</td>
    <td class="center">75</td>
    <td>1,204 ft</td>
    <td>29,686</td>
    <td class="center">4/5</td>
  </tr>
  <tr class="cellcolor">
    <td>Magic City, ID</td>
    <td class="center">June 25th</td>
    <td class="center">74</td>
    <td class="">5,312 ft</td>
    <td>50</td>
    <td class="center">3/5</td>
  </tr>
  <tr>
    <td>Bountiful, UT</td>
    <td class="center"> July 10th</td>
    <td class="center">91</td>
    <td>4,226 ft</td>
    <td>41,173</td>
    <td class="center">4/5</td>
  </tr>
  <tr class="cellcolor">
    <td>Last Chance, CO</td>
    <td class="center">July 23rd</td>
    <td class="center">102</td>
    <td>4,780 ft</td>
    <td>265</td>
    <td class="center">3/5</td>
  </tr>
  <tr>
    <td rowspan="2">Truth or Consequences, NM</td>
    <td class="center">August 9th</td>
    <td class="center">93</td>
    <td rowspan="2">4,242 ft</td>
    <td rowspan="2">7,289</td>
    <td class="center">5/5</td>
  </tr>
  <tr>
    <td class="center">August 27th</td>
    <td class="center">98</td>
    <td class="center">
      <table>
        <tr>
          <th>Tess</th>
          <td>5/5</td>
        </tr>
        <tr>
          <th>Tony</th>
          <td>4/5</td>
        </tr>
      </table>
    </td>
  </tr>
  <tr class="cellcolor">
    <td>Why, AZ</td>
    <td class="center">August 18th</td>
    <td class="center">104</td>
    <td>860 ft</td>
    <td>480</td>
    <td class="center">3/5</td>
  </tr>
</table>

小表格为:

      <table>
        <tr>
          <th>Tess</th>
          <td>5/5</td>
        </tr>
        <tr>
          <th>Tony</th>
          <td>4/5</td>
        </tr>
      </table>

使其居中的CSS为:

table table
{
  margin-left:      20px;
  margin-right:     20px;
}

效果:

技术分享图片

综上,在一个表格内嵌套另一个表格时,居中的一种方法为设置小表格的外边距。

<HTML>在一个表格内嵌套另一个表格时,如何居中?

原文:https://www.cnblogs.com/isAndyWu/p/11462938.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!