html - 将表格放在 div 上

标签 html css html-table

<div id="container">

<div class="main_div">

  <div class="cell1">1</div>
  <div class="cell2">2</div>

    <table>
     <tr>

       <td > The Tag </td>
        <td> The  Tag </td>
             .....
          more data
      </tr>

     </table>
</div>
</div>

</body>
</html>

Here the Table won't fit the container when I try to do. How can achieve to fit the table in "container tag? any idea?

CSS

#container{
margin:0 auto;
width:640px;
}

Table 
  width:900px;

/* 我应该如何将容器缩小到表格宽度 */还是没有解决方案? 我的容器有左右两侧的间隙,当我包括 table 时它看起来很奇怪并且不适合容器盒?

最佳答案

您无法将 900 像素的表格放入 640 像素的容器中。最好在其中一个中声明宽度并让另一个采用该宽度:

#container { width: 900px; }
table { width: 100%; }

关于html - 将表格放在 div 上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3334356/

相关文章:

css - 在 Chrome 中检查元素时空白消失

javascript - 为什么图片上传不显示图片预览文本?

javascript - 如何在打印时对齐文本

JavaScript 和复选框 - 过滤

PHP 表数据输出不保留结构

javascript - 停止我的页面中的所有表单提交

javascript - 动态调整 Flash 对象的大小以填充窗口

html - 对齐图例标签内的两个元素

html - 用 CSS 完成的水平导航栏

html - flex 布局(使用 Angular Material )在某些平台上中断