一种方法为中心TD在TR?方法、中心、TR、TD

2023-09-11 23:35:10 作者:爱情路上少不了你我她

我工作的HTML电子邮件,并试图居中的绿色TD白色TR所以,有一个20像素的白色边缘的绿色框的左侧和右侧。

我试着设置为绿色部分TD的宽度和设置保证金0汽车,但绿色只是扩展到TR的宽度。

试图把在2个达阵,推动绿色TD进入中心,而且没有任何工作

包括code段,我有与具有#a6d971的TR麻烦。

 <表CELLSPACING =0的cellpadding =0的边界=0WIDTH =600HEIGHT =BGCOLOR =的风格=保证金:0汽车;>
    < TBODY>
        &其中; TR>
            < TD风格=保证金:0汽车;>
                < IMG WIDTH =600HEIGHT =23填充=0SRC =财产/ graphic_scalloped_top.pngALT =的风格=显示:块; />
            < / TD>
        < / TR>
        < TR BGCOLOR =#FFF高度=75>
            < TD VALIGN =顶的风格=文本对齐:中心;>
                < p风格=保证金:0;填充底:的3px;填充顶:的3px;颜色:#545d69;字体大小:24PX;文本对齐:中心;字体家庭:宋体,黑体;>
                    正规的销售每天都在发生
                &所述; / P>
                < p风格=保证金:0;填充底:的3px;填充顶:的3px;颜色:#4bc1d6;字体大小:16像素;文本对齐:中心;字体家庭:宋体,黑体;>
                    上午9时 - 晚上11时
                &所述; / P>
            < / TD>
        < / TR>


        < TR BGCOLOR =#FFF高度=75填充=10>
            < TD BGCOLOR =#000宽度=20>< / TD>
            < TD BGCOLOR =#a6d971WIDTH =300的风格=保证金:10;>
            < / TD>
            < TD BGCOLOR =#000宽度=20>< / TD>
        < / TR>



        &所述; TR BGCOLOR =#FFF>
            < TD VALIGN =顶>
                <表CELLSPACING =0的cellpadding =10的边界=0ALIGN =中心WIDTH =100%BGCOLOR =#FFF的风格=>
                    < TBODY>
                        &其中; TR>
                            < TD高度=80的风格=字体家庭:黑体,宋体,无衬线;字体大小:18像素;字体重量:大胆;颜色:#555;背景:网址(资产/ graphic_9am.png ')不重复;背景位置:10%中心;填充:10px的;保证金:0;>
                                < H3>玖玖@< / H3>
                                < P>燃油起来!礼服,长袍和其他项目包括:LT; / P>
                            < / TD>
                        < / TR>




                        &其中; TR>

                        < / TR>

                    < / TBODY>
                < /表>
            < / TD>
        < / TR>


        &其中; TR>
            < TD风格=保证金:0汽车;>
                < IMG WIDTH =600HEIGHT =23填充=0SRC =财产/ graphic_scalloped_bottom.pngALT =的风格=显示:块; />
            < / TD>
        < / TR>
    < / TBODY>
< /表>
 

解决方案

切换到DIV的和CSS,大多数的邮件客户端支持的款式pretty的好,你可以使用DIV的TD元素在里面,它会很容易中心或你可能想其他的事情。

例如

 < TR风格=backgorund颜色:白色>
< TD风格=背景颜色:绿色>
< D​​IV的风格=背景颜色:紫色;保证金右:20像素;保证金左:20px的>内容此处< / DIV>
< / TD>
< / TR>
 
c 使用正则表达式获取TR中的多个TD Python爬虫基础教程 正则表达式抓取入门...

另外请注意,如果你使用DIV的,你也可避免表。

Am working on HTML email and trying to center a green TD in a white TR so that there's a 20px white margin on the left and right of the green box.

I tried setting TD width for the green portion and setting margin 0 auto but the green just expands to the width of the TR.

Tried putting in 2 more TDs to push the green TD into the center and that didn't work either

Including the code snippet, am having trouble with the TR that has #a6d971.

<table cellspacing="0" cellpadding="0" border="0" width="600" height="" bgcolor="" style="margin: 0 auto;">
    <tbody>
        <tr>
            <td style="margin: 0 auto;">
                <img width="600" height="23" padding="0" src="assets/graphic_scalloped_top.png" alt="" style="display: block;" />
            </td>
        </tr>
        <tr bgcolor="#fff" height="75">
            <td valign="top" style="text-align:center;">
                <p style="margin:0; padding-bottom: 3px; padding-top: 3px; color:#545d69; font-size: 24px; text-align:center; font-family: Arial, Helvetica;">
                    Regular sales happen every day
                </p>
                <p style="margin:0; padding-bottom: 3px; padding-top: 3px; color:#4bc1d6; font-size: 16px; text-align:center; font-family: Arial, Helvetica;">
                    9am - 11pm
                </p>
            </td>
        </tr>


        <tr bgcolor="#fff" height="75" padding="10">
            <td bgcolor="#000" width="20"></td>
            <td bgcolor="#a6d971" width="300" style="margin: 10;">
            </td>
            <td bgcolor="#000" width="20"></td>
        </tr>



        <tr bgcolor="#fff">
            <td valign="top">
                <table cellspacing="0" cellpadding="10" border="0" align="center" width="100%" bgcolor="#fff" style="">
                    <tbody>
                        <tr>
                            <td height="80" style="font-family: Helvetica, Arial, sans-serif; font-size: 18px; font-weight: bold; color: #555; background:url('assets/graphic_9am.png') no-repeat; background-position: 10% center; padding:10px; margin:0;">
                                <h3>Nine @ Nine</h3>
                                <p>Fuel up! Dresses, tunics and other items including:</p>
                            </td>
                        </tr>




                        <tr>

                        </tr>

                    </tbody>
                </table>
            </td>
        </tr>


        <tr>
            <td style="margin: 0 auto;">
                <img width="600" height="23" padding="0" src="assets/graphic_scalloped_bottom.png" alt="" style="display: block;" />
            </td>
        </tr>
    </tbody>
</table>

解决方案

Switch to DIV's and CSS, most emails client supports styles pretty well, you can use a DIV inside your TD element, it'll be easy to center or do other things you might want.

For Example

<tr style="backgorund-color: white">
<td  style="background-color: green">
<div style="background-color: purple;margin-right: 20px; margin-left: 20px">Content Here</div>
</td>
</tr>

Also note if you use DIV's you can also avoid tables.