表格居中和边距问题

保罗

我正在为基于表格格式的电子邮件创建模板以保持一致性。我在使用两个样式元素时遇到问题。

  1. .productWrap- 我无法border-bottom显示,并且保证金没有增加。
  2. 我无法让太阳的图像与容器的中心对齐。我尝试添加text-align: center;margin:0 auto 30px 0;display:block;<tr>图像本身。都不工作。

有没有人看到我在这两件事上做错了什么?

img {
    border: none;
    -ms-interpolation-mode: bicubic;
    max-width: 100%;
}
body {
    background-color: #f6f6f6;
    font-family: sans-serif;
    -webkit-font-smoothing: antialiased;
    font-size: 16px;
    line-height: 1.4em;
    margin: 0;
    padding: 0;
    -ms-text-size-adjust: 100%;
    -webkit-text-size-adjust: 100%;
}
table {
    border-collapse: separate;
    mso-table-lspace: 0pt;
    mso-table-rspace: 0pt;
    width: 100%;
}
table td {
    font-family: sans-serif;
    font-size: 14px;
    vertical-align: top;
}
/* -------------------------------------

            BODY & CONTAINER

        ------------------------------------- */
.red {
	color: #b82222;
	font-weight: bold;
}
p {
	font-family: sans-serif;
	font-size: 16px;
	line-height: 1.4em;
	color: #4d4d4d;
}
.bold {
	font-weight: bold;
}
.signature {
	margin-top: 30px;
	font-style: italic;
}
.container {
    display: block;
    margin: 0 auto !important;
    max-width: 580px;
    padding: 10px;
    width: 580px;
}
.content {
    box-sizing: border-box;
    display: block;
    margin: 0 auto;
    max-width: 580px;
    padding: 10px;
}
.main {
    background: #fff;
    border-radius: 3px;
    width: 100%;
}
.wrapper {
    box-sizing: border-box;
    padding: 20px;
}
.footer {
    clear: both;
    padding-top: 10px;
    text-align: center;
    width: 100%;
	max-width: 580px;
	margin: 0 auto;
	display: block;
}
.footer td, .footer p, .footer span, .footer a {
    color: #999999;
    font-size: 12px;
    text-align: center;
}

/* ------- Product Section ------- */
.productWrap {
	position: relative;
	width: 100%;
	height: 250px;
	margin: 20px auto;
	padding: 10px 0;
	border-bottom: 3px solid #CCC;
	z-index: 1;
}
.productImgCont {
	width: 300px;
	height: auto;
}
.productImg {
	width: 100%;
	height: auto;
}
.productContent {
	width: 250px;
	padding: 0 10px;
}
.productName {
	color: #4d4d4d;
	font-family: "Oswald", sans-serif;
	font-size: 1.1rem;
}
.productName:after {
	content: '';
	display: block;
	height: 4px;
	width: 100px;
	background: #1b8c00;
	margin-bottom: 10px;
}
.productLink {
	color: #1b8c00;
	font-family: Verdana;
	font-size: .9rem;
	text-transform: uppercase;
}
<table border="0" cellpadding="0" cellspacing="0" style="width:600px;max-width:600px;margin:0 auto;">
    <tr>
        <td class="container">
            <div class="content">
                <table class="main">
                    <!-- START MAIN CONTENT AREA -->
                    <tr>
                        <td class="wrapper">
                            <table border="0" cellpadding="0" cellspacing="0">
                                <tr style="width: 100%;text-align:center;display:block;margin:0 auto 30px auto;">
                                    <td>
                                    <p>
											<a href="">
												<img src="https://solarsystem.nasa.gov/system/downloadable_items/519_solsticeflare.jpg">
											</a>
                                        </p>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
										<p>Hi John,</p>
                                        <p>Here's your daily mower update</p>
                                    </td>
								</tr>
								<tr class="productWrap">
									<td class="productImgCont">
										<img src="https://www.getmowers.com/wp-content/uploads/w2464-1.jpeg" class="productImg" alt="$product_name">
                                    </td>
									<td class="productContent">
										<p class="productName">60IN JOHN DEERE 1026R SUB-COMPACT UTILITY 4X4 TRACTOR W/ 25HP YANMAR!!</p>
										<p class="productCost">$10,500.00</p>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
           </div>     
        </td>
        <td>&nbsp;</td>
    </tr>
</table>

纳夫普雷特·维克

我在 .productWrap 中添加了“display:block”。对于图像,我删除了一些样式属性,效果很好。

img {
    border: none;
    -ms-interpolation-mode: bicubic;
    max-width: 100%;
}

body {
    background-color: #f6f6f6;
    font-family: sans-serif;
    -webkit-font-smoothing: antialiased;
    font-size: 16px;
    line-height: 1.4em;
    margin: 0;
    padding: 0;
    -ms-text-size-adjust: 100%;
    -webkit-text-size-adjust: 100%;
}

table {
    border-collapse: separate;
    mso-table-lspace: 0pt;
    mso-table-rspace: 0pt;
    width: 100%;
}

table td {
    font-family: sans-serif;
    font-size: 14px;
    vertical-align: top;
}


/* -------------------------------------

            BODY & CONTAINER

        ------------------------------------- */

.red {
    color: #b82222;
    font-weight: bold;
}

p {
    font-family: sans-serif;
    font-size: 16px;
    line-height: 1.4em;
    color: #4d4d4d;
}

.bold {
    font-weight: bold;
}

.signature {
    margin-top: 30px;
    font-style: italic;
}

.container {
    display: block;
    margin: 0 auto !important;
    max-width: 580px;
    padding: 10px;
    width: 580px;
}

.content {
    box-sizing: border-box;
    display: block;
    margin: 0 auto;
    max-width: 580px;
    padding: 10px;
}

.main {
    background: #fff;
    border-radius: 3px;
    width: 100%;
}

.wrapper {
    box-sizing: border-box;
    padding: 20px;
}

.footer {
    clear: both;
    padding-top: 10px;
    text-align: center;
    width: 100%;
    max-width: 580px;
    margin: 0 auto;
    display: block;
}

.footer td,
.footer p,
.footer span,
.footer a {
    color: #999999;
    font-size: 12px;
    text-align: center;
}


/* ------- Product Section ------- */

.productWrap {
    position: relative;
    width: 100%;
    height: 250px;
    margin: 20px auto;
    padding: 10px 0;
    border-bottom: 3px solid #CCC;
    z-index: 1;
    display: block;
}

.productImgCont {
    width: 300px;
    height: auto;
}

.productImg {
    width: 100%;
    height: auto;
}

.productContent {
    width: 250px;
    padding: 0 10px;
}

.productName {
    color: #4d4d4d;
    font-family: "Oswald", sans-serif;
    font-size: 1.1rem;
}

.productName:after {
    content: '';
    display: block;
    height: 4px;
    width: 100px;
    background: #1b8c00;
    margin-bottom: 10px;
}

.productLink {
    color: #1b8c00;
    font-family: Verdana;
    font-size: .9rem;
    text-transform: uppercase;
}
<table border="0" cellpadding="0" cellspacing="0" style="width:600px;max-width:600px;margin:0 auto;">
    <tr>
        <td class="container">
            <div class="content">
                <table class="main">
                    <!-- START MAIN CONTENT AREA -->
                    <tr>
                        <td class="wrapper">
                            <table border="0" cellpadding="0" cellspacing="0">
                                <tr style="width: 100%;margin:0 auto 30px auto;">
                                    <td style="text-align: center;">
                                        <p>
                                            <a href="">
                                            <img src="https://solarsystem.nasa.gov/system/downloadable_items/519_solsticeflare.jpg" width="128">
                                            </a>
                                        </p>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <p>Hi John,</p>
                                        <p>Here's your daily mower update</p>
                                    </td>
                                </tr>
                                <tr class="productWrap">
                                    <td class="productImgCont">
                                        <img src="https://www.getmowers.com/wp-content/uploads/w2464-1.jpeg" class="productImg" alt="$product_name">
                                    </td>
                                    <td class="productContent">
                                        <p class="productName">60IN JOHN DEERE 1026R SUB-COMPACT UTILITY 4X4 TRACTOR W/ 25HP YANMAR!!</p>
                                        <p class="productCost">$10,500.00</p>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </div>
        </td>
        <td>&nbsp;</td>
    </tr>
</table>

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章