css - 删除所有填充和边距表 HTML 和 CSS

标签 css html-table margin padding

我有这张表:

<body>
    <table id="page" >
        <tr id="header" >
            <td colspan="2" id="tdheader" >je suis</td>
        </tr>
        <tr>
            <td>1</td>
            <td>2</td>
        </tr>
    </table>
</body>

这是CSS

html, body, #page {
    height:100%;
    width:100%;
    margin:0;
    padding:0;
}

#header {
    margin:0;
    padding:0;
    height:20px;
    background-color:green;
}

我想删除所有边距和填充,但我总是有:

enter image description here

我该如何解决?

最佳答案

尝试使用这个 CSS:

/* Apply this to your `table` element. */
#page {
   border-collapse: collapse;
}

/* And this to your table's `td` elements. */
#page td {
   padding: 0; 
   margin: 0;
}

关于css - 删除所有填充和边距表 HTML 和 CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16427903/

相关文章:

html - 填充/边距问题

html - CSS 主体宽度未填充 100%

javascript - 使用javascript修改网页的CSS

javascript - ui-使用相同的数据源滚动两个表并同步滚动两个表

html - 在后续页面上打印带有自定义标题的 html 表格

css - CSS 中的负边距如何工作以及为什么 (margin-top :-5 ! = margin-bottom :5)?

CSS - IE 不从最后一个 div 获取边距底部

jquery - IE 10 不接受 <li> 标签类型属性的自定义值

javascript - Vue 3 类与变量的绑定(bind)是否需要内联?

html - 使表格与标题在同一行开始