使用表作为另一个表的边框

时间:2016-01-10 05:01:37

标签: html css html-table

尝试创建一个带有内容边框的漂亮的html电子邮件,但是没有想出来.....总有一些东西.....感谢您的帮助!



<table bgcolor="#ACD13C" width="100%" cellpadding="0" cellspacing="0">
  <tr>
    <td>
      <table bgcolor="#ffffff" width="500" cellpadding="0" cellspacing="0">
        <tr>
          <td>Text goes here</td>
        </tr>
      </table>
    </td>
  </tr>
</table>
&#13;
&#13;
&#13;

4 个答案:

答案 0 :(得分:1)

像这样???

<!DOCTYPE  html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>HTML Email</title>
    <style type="text/css">
        body {
            margin: 0;
            padding: 0;
            min-width: 100%!important;
        }

        .content {
            width: 100%;
            max-width: 600px;
        }

        .header {
            padding: 40px 30px 20px 30px;
        }
    </style>

    <style type="text/css">
        @media only screen and (min-device-width: 601px) {
            .content {
                width: 600px !important;
            }
        }
    </style>
</head>
<body>
    <table width="100%" bgcolor="#ACD13C" border="0" cellpadding="0" cellspacing="0">
        <tr>
            <td>
                <table class="content" align="center" cellpadding="0" cellspacing="0" border="0">
                    <tr>
                        <td class="header" bgcolor="#ACD13C">
                            Text goes here
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</body>
</html>

答案 1 :(得分:0)

那样的东西?

&#13;
&#13;
td {
       border: 1px solid black;
    }
&#13;
<table bgcolor="#ACD13C" width="100%" cellpadding="0" cellspacing="0">
  <tr>
    <td>
      <table bgcolor="#ffffff" width="500" cellpadding="0" cellspacing="0">
        <tr>
          <td>Text goes here</td>
        </tr>
      </table>
    </td>
  </tr>
</table>
&#13;
&#13;
&#13;

答案 2 :(得分:0)

你希望看到这样吗??

&#13;
&#13;
<!DOCTYPE  html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>HTML Email</title>
    <style type="text/css">
        body {
            margin: 0;
            padding: 0;
            min-width: 100%!important;
        }

        .content {
            width: 100%;
            max-width: 600px;
        }

        .header {
            padding: 40px 30px 20px 30px;
        }
    </style>

    <style type="text/css">
        @media only screen and (min-device-width: 601px) {
            .content {
                width: 600px !important;
            }
        }
    </style>
</head>
<body>
    <table width="100%" bgcolor="#ACD13C" border="0" cellpadding="0" cellspacing="0">
        <tr>
            <td>
                <table class="content" align="center" cellpadding="0" cellspacing="0" border="0">
                    <tr>
                        <td class="header" bgcolor="#ffffff">
                            Text goes here
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</body>
</html>
&#13;
&#13;
&#13;

答案 3 :(得分:0)

您可以将表格包裹在div中,使其背景为绿色和width:100%,将表格的背景更改为白色,将宽度更改为500,{{1将表格置于中心位置,如下所示:

JS Fiddle- updated

margin:0 auto