删除HTML表格中单元格周围的空间

时间:2017-05-04 13:44:06

标签: html html-email

我正在尝试构建我的第一个HTML电子邮件。我希望标头图形与单元格的边缘齐平,但是有一个小的白色边框,我似乎可以摆脱它。可以做些什么呢?

{{1}}

3 个答案:

答案 0 :(得分:0)

首先通过添加style="border: 0px"从页面中删除边距,然后将cellspacing和cellpadding添加到表和所有父表。

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
http//www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <title></title>
    </head>
    <body style="margin:0px">
    <!-- Wrapper (pseudo body tag) -->
        <table border="1" align="center" cellpadding="0" cellspacing="0" width="100%">
            <tbody>
                <tr>
                    <td align="center" valign="top" cellpadding="0" cellspacing="0" width="100%">

                        <!--Body Table-->
                        <table border="0" bgcolor="black" cellpadding="0" cellspacing="0" width="">
                            <tbody>    
                                <tr>
                                    <td align="center" valign="top" width="">

                                        <!--Content Table-->
                                        <table border="0" bgcolor="white" cellpadding="0" cellspacing="0" width="">
                                            <tbody>    
                                                <tr>
                                                    <td lign="center" valign="top" width="">
                                                        <table border="0" bgcolor="white" cellpadding="0" cellspacing="0" width="">
                                                            <tbody>
                                                                <tr>
                                                                    <td align="center" valign="top" width="">

                                                                        <img src="https://docs.google.com/uc?id=0B3ruYAyZeJR3clo3dmJUbW5Ya1E" vspace="0" hspace="0">
                                                                        
                                                                    </td>
                                                                </tr>                                    
                                                            </tbody>
                                                        </table>
                                                        <table border="1" bgcolor="white" align="center" cellpadding="" cellspacing="0" width="600"> 
                                                            <tbody>
                                                                <tr>
                                                                    <td align="center" valign="top" width="600">
                                                                        <p>subhead</p>
                                                                    </td>
                                                                </tr>
                                                                <tr>
                                                                    <td align="center" valign="top" width="600">
                                                                        <p>divider</p>
                                                                    </td>
                                                                </tr>                                                                <tr>
                                                                    <td align="center" valign="top" width="600">
                                                                        <p>Story</p>
                                                                    </td>
                                                                </tr>
                                                                <tr>
                                                                    <td align="center" valign="top" width="600">
                                                                        <p>Picture</p>
                                                                    </td>
                                                                </tr>
                                                                <tr>
                                                                    <td align="center" valign="top" width="600">
                                                                        <p>divider</p>
                                                                    </td>
                                                                </tr>
                                                            </tbody>
                                                        </table>
                                                    </td>
                                                </tr>                                            
                                            </tbody>
                                        </table>
                                        <!--End Content Table--> 
                                        
                                        <!--Footer Table-->
                                        <table border="1" cellpadding="0" cellspacing="0" width="600">
                                            <tbody>    
                                                <tr>
                                                    <td style="color:white" align="center" valign="top" width="">
                                                        
                                                        <p>footer1</p>

                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td style="color:white"  align="center" valign="top" width="">
                                                        
                                                        <p>footer2</p>

                                                    </td>
                                                </tr>                                            
                                            </tbody>
                                        </table>
                                        <!--End Footer Table--> 

                                    </td>
                                </tr>
                            </tbody>
                        </table>
                        <!--End Body Table-->

                    </td>
                </tr>
            </tbody>    
        </table>
    </body>
</html>

答案 1 :(得分:0)

我对你的桌子做了一些改动。删除了表格边框,因此表格不会显示每个单元格和表格本身的边框。此外,所有图片都需要 style =&#34; display:block&#34; ,因此周围没有多余空格。

&#13;
&#13;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
http//www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <title></title>
    </head>
    <body>
    <!-- Wrapper (pseudo body tag) -->
        <table border="1" align="center" cellpadding="0" cellspacing="0" width="100%">
            <tbody>
                <tr>
                    <td align="center" valign="top" width="100%">

                        <!--Body Table-->
                        <table border="0" bgcolor="black" cellpadding="10" cellspacing="0" width="">
                            <tbody>    
                                <tr>
                                    <td align="center" valign="top" width="">

                                        <!--Content Table-->
                                        <table border="0" bgcolor="white" cellpadding="0" cellspacing="0" width="">
                                            <tbody>    
                                                <tr>
                                                    <td lign="center" valign="top" width="">
                                                        <table width="" border="0" cellpadding="" cellspacing="0" bgcolor="black">
                                                            <tbody>
                                                                <tr>
                                                                    <td align="center" valign="top" width="">

                                                                        <img src="https://docs.google.com/uc?id=0B3ruYAyZeJR3clo3dmJUbW5Ya1E" vspace="0" hspace="0" style="display:block;">
                                                                        
                                                                    </td>
                                                                </tr>                                    
                                                            </tbody>
                                                        </table>
                                                        <table border="0" bgcolor="white" align="center" cellpadding="" cellspacing="0" width="600"> 
                                                            <tbody>
                                                                <tr>
                                                                    <td align="center" valign="top" width="600">
                                                                        <p>subhead</p>
                                                                    </td>
                                                                </tr>
                                                                <tr>
                                                                    <td align="center" valign="top" width="600">
                                                                        <p>divider</p>
                                                                    </td>
                                                                </tr>                                                                <tr>
                                                                    <td align="center" valign="top" width="600">
                                                                        <p>Story</p>
                                                                    </td>
                                                                </tr>
                                                                <tr>
                                                                    <td align="center" valign="top" width="600">
                                                                        <p>Picture</p>
                                                                    </td>
                                                                </tr>
                                                                <tr>
                                                                    <td align="center" valign="top" width="600">
                                                                        <p>divider</p>
                                                                    </td>
                                                                </tr>
                                                            </tbody>
                                                        </table>
                                                    </td>
                                                </tr>                                            
                                            </tbody>
                                        </table>
                                        <!--End Content Table--> 
                                        
                                        <!--Footer Table-->
                                        <table border="0" cellpadding="0" cellspacing="0" width="600">
                                            <tbody>    
                                                <tr>
                                                    <td style="color:white" align="center" valign="top" width="">
                                                        
                                                        <p>footer1</p>

                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td style="color:white"  align="center" valign="top" width="">
                                                        
                                                        <p>footer2</p>

                                                    </td>
                                                </tr>                                            
                                            </tbody>
                                        </table>
                                        <!--End Footer Table--> 

                                    </td>
                                </tr>
                            </tbody>
                        </table>
                        <!--End Body Table-->

                    </td>
                </tr>
            </tbody>    
        </table>
    </body>
</html>
&#13;
&#13;
&#13;

如果有帮助,请告诉我。

答案 2 :(得分:0)

您需要添加: cellpadding =“0”cellspacing =“0”border =“0” 到你的所有表(除非你有意添加cellpadding等) - 这摆脱了额外的间距。

然后你还应该将所有图像设置为具有内联样式的显示:块;

我刚测试了它,它摆脱了额外的间距:)