如何使用css使文本与其下方的单元格对齐?

时间:2015-07-13 23:21:12

标签: html css

我正在设计一封电子邮件,但我不确定如何使文字与其下方的行对齐。我想要“我们的天气专家”和“正在寻找你”。伸展整个桌子并与其下方的行齐平,包括段落并了解更多按钮。我尝试使用字母间距和不同种类的填充,但这是否可能?

它应该是这样的:

enter image description here

我还尝试将“Our Weather Experts”行设置为瘦文本,但font-weight:lighter属性似乎也不起作用。

任何帮助将不胜感激。

                   

<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<style type="text/css">

    .borderbottom {border-bottom: 1px solid #dadada;}
    .innerpadding {padding: 30px 30px 30px 30px;}

    /* CLIENT-SPECIFIC STYLES */
    #outlook a{padding:0;} /* Force Outlook to provide a "view in browser" message */
    .ReadMsgBody{width:100%;} .ExternalClass{width:100%;} /* Force Hotmail to display emails at full width */
    .ExternalClass, .ExternalClass p, .ExternalClass span, .ExternalClass font, .ExternalClass td, .ExternalClass div {line-height: 100%;} /* Force Hotmail to display normal line spacing */
    body, table, td, a{-webkit-text-size-adjust:100%; -ms-text-size-adjust:100%;} /* Prevent WebKit and Windows mobile changing default text sizes */
    table, td{mso-table-lspace:0pt; mso-table-rspace:0pt;} /* Remove spacing between tables in Outlook 2007 and up */
    img{-ms-interpolation-mode:bicubic;} /* Allow smoother rendering of resized image in Internet Explorer */

    /* RESET STYLES */
    body{margin:0; padding:0;}
    img{border:0; height:auto; line-height:100%; outline:none; text-decoration:none;}
    table{border-collapse:collapse !important;}
    body{height:100% !important; margin:0; padding:0; width:100% !important;}

    /* iOS BLUE LINKS */
    .appleBody a {color:#68440a; text-decoration: none;} 
    .appleFooter a {color:#999999; text-decoration: none;} 


</style>
</head>
<body yahoo="fix" style="margin: 0; padding: 0; ">
<table class="container" width="640" align="center" cellpadding="0" cellspacing="0" border="0" style="margin: 0 auto; padding: 0;">
<tr>
    <td valign="top" align="center" bgcolor="#ffffff">
            <div class="mobile-only" style="text-indent: -99999em; display: none; height: 0; width: 0; overflow: hidden; max-height: 0;">
                <img src="http://image.email-libertymutual.com/lib/fe6a15707464047f7c1c/m/1/CatAuto-Header-Mobile-320x159.jpgg" border="0">
            </div>
            <div class="no-mobile">
                <img src="http://image.email-libertymutual.com/lib/fe6a15707464047f7c1c/m/1/CatAuto-Header-Desktop-640x220.jpg" border="0">
            </div>
     </td>
</tr>
<tr>
    <td valign="top" align="center" bgcolor="#ffffff" style="padding:30px;" >
        <table cellpadding="0" cellspacing="0" border="0" width="600">
            <tr>
                <td colspan="2" style="letter-spacing: 3px; font-family: Arial, Helvetica, sans-serif; font-size:43px; color: #002663">
                OUR WEATHER EXPERTS
                </td>
            </tr>
            <tr>
                <td colspan="2" style="letter-spacing: 3px; font-family: Arial, Helvetica, sans-serif; font-size:36px; color: #002663">
                <strong>ARE LOOKING OUT FOR YOU.</strong>
                </td>
            </tr>
            <tr>
                            <td style="font-family: Arial, Helvetica, sans-serif; font-size:16px; color:#666666; line-height:20px; padding:20px 35px 25px 0px;" align="left" class="borderbottom">
                            Your area is likely to receive severe storms in the upcoming months. We've prepared information and tips to help protect you and your loved ones this season.
                            </td>
                            <td style="font-family: Arial, Helvetica, sans-serif; vertical-align:top; padding: 20px 0px 30px 0px"; align="left" class="borderbottom">
                                <a href="#"><img src="http://image.email-libertymutual.com/lib/fe6a15707464047f7c1c/m/1/CatAuto-Button-Learn-More-139x38.jpg" style="display:block;" width="139" height="38"></a>
                            </td>                                                       
                        </tr>
        </table>
    </td> 
</tr>
</table>

</body>
</html>

1 个答案:

答案 0 :(得分:0)

你想做的是

text-align:justify;

但只有一行文字会让人觉得有点乱。

您需要添加宽度为100%的空容器才能将文本推送到最后。

<span style="display:inline-block;width:100%;"></span>

然后它会在文本下方添加额外的空间,因此您需要调整行高。

请参阅小提琴https://jsfiddle.net/y7vp8oz0/