html - 如何在文本对齐 :left? 时将 tbody 居中放置在表格中

标签 html css html-table

#present-container{
        background-color: antiquewhite;
        text-align: center;

    }
    #presentation{
        display: inline-block;
        text-align: center;
    }
    #tabela{
       display: inline-block;
       width: 40%;
       margin: 10px;
       padding: 25px;
       border: 2px solid #e4d8ba;
       border-radius: 8px;
       border-collapse: collapse;
    }
    
    #tabela tbody {

    }
    
    #tabela th, td {
       padding: 15px;
       text-align: left;
       border-top: 2px solid #e4d8ba;
    }
    
    .top{
       border: none;
    }
<div id="present-containter">
  <div id="presentation">

    <table id="tabela">
      <tr><td class="top">Nearby</td><td class="top"><li>Beach: 500 meters (Pebble)</li><li>Restaurant: 1 km</li><li>Market: 200 meters</li></td></tr>
      <tr><td>Included in price</td><td><li>Bedlinen including towels</li><li>Final Cleaning</li><li>Consumption costs</li></td></tr>
      <tr><td>other</td><td><li>free WiFi</li><li>pets not allowed</li></td></tr>
    </table>
  </div>
</div>

检查这张图片: http://prntscr.com/kpy2mt

如何在保持 text-align: left 的同时使表格主体或表格列在表格中居中。

最佳答案

如果我的理解正确,您正在寻找类似的东西。还去清理了你的语法,这在很多方面都是无效的,但希望这能有所帮助,干杯。

#present-container {
  border: 2px solid #e4d8ba;
  border-radius: 8px;
  background-color: antiquewhite;
  margin: 0 auto;
}

#tabela {
  padding: 25px;
  border-collapse: collapse;
  margin: 10px auto;
}

#tabela tr:not(:last-child) {
  border-bottom: 2px solid #e4d8ba;
}

#tabela td {
  padding: 15px;
}
<div id="present-container">

    <table id="tabela">
      <tbody>
        <tr>
          <td>
            Nearby
          </td>
          <td>
            <ul>
              <li>Beach: 500 meters (Pebble)</li>
              <li>Restaurant: 1 km</li>
              <li>Market: 200 meters</li>
            </ul>
          </td>
        </tr>
        <tr>
          <td>
            Included in price
          </td>
          <td>
            <ul>
              <li>Bedlinen including towels</li>
              <li>Final Cleaning</li>
              <li>Consumption costs</li>
            </ul>
         </td>
        </tr>
        <tr>
          <td>
            other
          </td>
          <td>
            <ul>
              <li>free WiFi</li>
              <li>pets not allowed</li>
            </ul>
          </td>
        </tr>
      </tbody>
    </table>
    
</div>

关于html - 如何在文本对齐 :left? 时将 tbody 居中放置在表格中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52145605/

相关文章:

javascript - PHP JS 链接动态列表

javascript - jquery改变背景大小

javascript - 修复了标题表,在 IE11(Internet Explorer)中使用 Jquery 滚动时单击 div 滚动条图标时会闪烁。

javascript - 如何将表头的 h-scroll 与表体的 h-scroll 链接起来,而不将表体的 v-scroll 与表头链接起来?

jquery - IE 漏洞 : toggleClass and overflow:hidden issue

html - 表格在 Wordpress 的移动设备中超出屏幕

javascript - PixiJS 调整渲染器大小但保持比例?

html - Google 图片广告超出父 div

javascript - 如何合并具有相同值的单元格

HTML 表体定位和滚动