简体   繁体   English

中间垂直对齐 outlook 表格单元格中的 href 文本

[英]Middle Vertical align a href text in table cell for outlook

Forgive me if this is simple, it's been a long time since I put some HTML together for email design.如果这很简单,请原谅我,我已经很长时间没有将一些 HTML 放在一起用于 email 设计。 I'm working on a template that I have received and have a button in the template that renders perfectly on the browser.我正在处理我收到的模板,并且模板中有一个可以在浏览器上完美呈现的按钮。

In outlook it's almost there, I'm trying to get the block to include the link, not just the text.在 outlook 中,它几乎就在那里,我试图让块包含链接,而不仅仅是文本。 giving a decent amount of height above and around the text to act as a button.在文本上方和周围提供适当的高度以充当按钮。 The line height on the td achieves the height of the block but I can't get the text to vertically align in the center of the block. td 上的行高达到了块的高度,但我无法让文本在块的中心垂直对齐。

Can anyone help me out?谁能帮我吗?

                <tr>
                    <td style=" background-color:#ffffff;
                                padding:17px 30px 17px 30px;
                                text-align: center;
                                mso-line-height-rule: exactly;  
                                line-height: 28px;
                                "

                        >
                        <a href="https://#"
                            target="_blank" title="" data-targettype="webpage" data-targetname=""
                            style=" background-color: #004752;
                                    border-radius: 17px;
                                    display:inline-block;
                                    text-decoration: none;
                                    color: #ffffff;
                                    ">
                                  
                            <strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Some Text&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
                       </a>
                    </td>
                </tr>

Moving the padding from td to a and applying a display:block' will achieve the result you want.paddingtd移动到a并应用display:block'将获得您想要的结果。

 <tr> <td style=" background-color:#ffffff; text-align: center; mso-line-height-rule: exactly;"> <a href="https://#" target="_blank" title="" data-targettype="webpage" data-targetname="" style=" background-color: #004752; border-radius: 17px; display:block; text-decoration: none; color: #ffffff; padding:17px 30px 17px 30px; line-height: 28px;"> <strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Some Text&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong> </a> </td> </tr>

There is a trick where making the line-height equal to the height will center the text.有一个技巧,使line-height等于height将使文本居中。

You can read more on vertically centering .您可以阅读有关垂直居中的更多信息。

 <a href="https://#" target="_blank" title="" data-targettype="webpage" data-targetname="" style=" background-color: #004752; height: 50px; line-height: 50px; border-radius: 17px; display:inline-block; text-decoration: none; color: #ffffff;">TEXT</a>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM