如何将1张桌子的<td>与另一张桌子对齐?

时间:2019-10-28 01:10:40

标签: html nested alignment

我是HTML / CSS的新手,我很难将Chicken Shop的营业时间,营业时间,营业时间与表格中的营业时间,营业时间和营业时间相对应。我希望日期和时间在每个类别的正下方对齐。例如营业时间(周日/周一),营业时间(9-3pm),营业时间(周二/周五)。以下是我的代码,任何建议将不胜感激!!!谢谢!!!

<table id="shops">
        <tr>
            <th>Shops</th>
            <th>Location</th>
            <th>Store Hours</th>
            <th>Products</th>
        </tr> <!-- Nested table for store hours and product types-->
        <tr>
            <td colspan="2"></td>
            <td>
                <table id="hours_table">    
                    <tr>
                        <th>OPEN</th>
                        <th>HOURS</th>
                        <th>CLOSE</th>
                    </tr>
                </table>
            </td>
            <td> 
                <table id="products_table">    
                    <tr>
                        <th>Animals</th>
                        <th>Cost</th>
                        <th>Items</th>
                        <th>Cost</th>
                    </tr>
                </table>
            </td>
        </tr>


        <tr>
            <td id="chicken_shop">Cuckoo House Chicken Shop</td>
            <td>West Natura</td>
            <td>
                <table id="chicken_hours"> 
                    <tr>
                        <td>SUN/MON/WED/THURS/SAT</td>
                        <td>9AM - 3PM</td>
                        <td>TUES/FRI</td>
                    </tr>
                </table>
            </td>
</table>

2 个答案:

答案 0 :(得分:0)

即使它是表头的一部分,也必须使用<td>来代替 <table> <thead> <tr> <td>Shops</td> <td>SOmethng</td> <td>Something#2</td> </tr> </thead> <tbody> <tr> <td>Something in the body of the table</td> <td>something</td> <tdSomething</td> </tr> </tbody> </table>

x = 1
buckets = {}
buckets = {'1':0, '2':0, '3':0, '4':0, '5':0, '6':0, '7':0, '8':0, '9':0}
while x < 20:
    j = x
    while j > 9:
        j = sum(int(digit) for digit in str(x))
    if str(j) in buckets:
        buckets[str(j)] += 1
    x += 1
print(buckets)

我建议使用w3schools.com以获得更多信息。此外,如果您希望在边框周围添加边框,则可以添加边框。

答案 1 :(得分:0)

您好,这是解决方法:

<table id="shops" border='1'>
  <tr>
    <th>Shops</th>
    <th>Location</th>
    <th>Store Hours</th>
    <th colspan="4">Products</th>
  </tr> <!-- Nested table for store hours and product types-->
  <tr>
    <td id="chicken_shop">Cuckoo House Chicken Shop</td>
    <td>West Natura</td>
    <td>
      <table width="333" id="hours_table" border='1'>
        <tr>
          <td>OPEN</td>
          <td>HOURS</td>
          <td>CLOSE</td>
        </tr>
        <tr>
          <td>SUN/MON/WED/THURS/SAT</td>
          <td>9AM - 3PM</td>
          <td>TUES/FRI</td>
        </tr>
      </table>
    </td>
    <th>Animals</th>
    <th>Cost</th>
    <th>Items</th>
    <th>Cost</th>
  </tr>
</table>

table image