html - IE7 中的额外空间,div 中有一个表

标签 html css internet-explorer-7

我已经尝试了所有可能适用于网络的解决方案,但未能弄清楚这一点。

这是演示问题的页面:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html lang="en">
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <title>Title Goes Here</title>
</head>

<body>
    <style>
        .centered_text {
            text-align:center;
        }
        .datagrid table { 
            width: 100%; 
            border-spacing: 0px;
        } 
        .datagrid {
            background: #FFFEE1; 
            border: thick solid #A31B2B;
        }
        .datagrid table td, .datagrid table th { 
            padding: 3px; 
        }
        .datagrid table tbody tr td { 
            border: thick solid #A31B2B;
        }
    </style>

    <div class="centered_text datagrid">
        <table>
            <tbody>
                <tr>
                    <td>1</td>
                    <td>2</td>
                    <td>3</td>
                </tr>
            </tbody>
        </table>
    </div>
</body>

当我在 Chrome 或 IE10 中查看时,看起来我希望它...div 边框和表格边框之间没有空格。但是,如果我将 IE 文档模式更改为 IE7,则表格周围会一直显示一个空格。

我们还是要支持IE7。如何让这个空间消失?

最佳答案

你也可以使用:

<div class="centered_text datagrid">
            <table cellpadding="0" cellspacing="0">
            </table>
    <div>

关于html - IE7 中的额外空间,div 中有一个表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18750594/

相关文章:

Javascript 函数不显示随机消息

html - CSS - 如何在不移动其他 div 的情况下将一个 div 放在浏览器的中心

php - 从 file_get_contents 更改/删除 html

javascript - 我可以更改 Javascript 中 css 样式的优先级吗?

css - iFrame 上的水平和垂直滚动 - ie7

jquery - IE7嵌套div显示bug

jquery - 添加类,最近的 div

javascript - 使用javascript代码的计算器

css - 不要为特定的父类应用 CSS

html - Reset.css 覆盖了 IE7/IE6 中的 colgroup 背景