zoukankan      html  css  js  c++  java
  • <HTML>在一个表格内嵌套另一个表格时,如何居中?

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

    假设大表格为:

    <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;
    }

    效果:

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

  • 相关阅读:
    malloc/free和new/delete的区别
    Vim Skills——Windows利用Vundle和Github进行Vim配置和插件的同步
    selenium自学笔记---ecshop购买脚本 xpath定位元素(下拉框,单选框)
    python基础09--闭包,装饰器
    python基础08--迭代器,生成器
    python基础07--函数
    python基础06--文件操作
    python基础05--深浅copy, set,bytes
    python基础04--list,cou,dict
    python基础03--int,bool,str
  • 原文地址:https://www.cnblogs.com/isAndyWu/p/11462938.html
Copyright © 2011-2022 走看看