如何使单元格的标题保持左对齐但以其他内容为中心?

时间:2015-07-23 06:37:43

标签: html css

我有两个并排的表格单元格,当由HTML简报的媒体查询触发时会叠加。我想要头条新闻"做好准备"和"保持有组织的#34;当响应代码触发时左对齐但是" margin:0px auto"导致所有内容居中。有没有办法让这些保持左对齐?如果我将它们从表格数据单元中移出其他内容,那么一切都会搞砸。

"保持井井有条"并且"做好准备"当代码响应时,标题会居中。我需要他们左对齐。

这就是它在移动设备上看起来的样子:http://imgur.com/vT3XhJ6

感谢任何帮助。

            <!DOCTYPE html>
            <!--

            -->
            <html lang="en">
            <head><META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW"><META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW"><META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
            <title></title>
            <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">
                table td {border-collapse:collapse;}   

                table[class=tblPreHeaderLinks] {
                    width: 100% !important;
                    height: 25px !important;
                    clear: both !important;
                    float: none !important;
                }

                .appleLinks2 a {
                    color:#333333 !important;
                    text-decoration: none !important;
                    }

                /* 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;} 

                /* MOBILE STYLES */

                @media screen and (max-width: 525px) {

                    body[yahoo] .block_td {display: block;}
                    .appleLinks2 a {
                    color:#545861 !important;
                    text-decoration: none !important;
                    }




                    body {
                            -webkit-text-size-adjust: 100%;
                            -ms-text-size-adjust: 100%;
                        }

                    div[class="mobilecontent"]{
                    display: block !important;
                    max-height: none !important;
                    }

                    /* ALLOWS FOR FLUID TABLES */
                    table[class="wrapper"]{
                      width:100% !important;
                    }

                    /* USE THESE CLASSES TO HIDE CONTENT ON MOBILE */
                    td[class="mobile-hide"]{
                      display:none;}

                    img[class="mobile-hide"]{
                      display: none !important;
                    }

                    img[class="img-max"]{
                      max-width: 100% !important;
                      width: 100% !important;
                      height:auto !important;
                    }

                    a.learnMore {
                        display: block;
                        text-align: center;
                    }

                    /* UTILITY CLASSES FOR ADJUSTING PADDING ON MOBILE */

                    td[class="section-padding"]{
                      padding: 10px 15px 5px 15px !important;
                    }

                     /* FULL-WIDTH TABLES */
                    table[class="responsive-table"]{
                      width:100%!important;
                    }

                    td[class="weatherTEXT"]{
                      font-size: 23px !important;
                      line-height: 27px !important;
                    }

                    td[class="weatherTEXT2"]{
                      font-size: 17px !important;
                      line-height: 21px !important;
                    }

                }


            </style>
            </head>
            <body yahoo="fix" style="margin: 0; padding: 0;" bgcolor="#f6f4f5">
            <style type="text/css">
            body { width: 100% !important; }
            </style>

            <table border="0" cellpadding="0" cellspacing="0" width="100%" class="wrapper" style="border:1px solid #e2e0e0;">
            <tr>
            <td align="center">




            <table cellpadding="0" cellspacing="0" width="640" class="wrapper" bgcolor="#f6f4f5">
                <tr>
                <td align="center">



                    <!--BODY-->
                    <table border="0" cellpadding="0" cellspacing="0" width="640" class="wrapper" bgcolor="#f6f4f5" align="center">
                    <tbody><tr>
                        <td width="640" align="center" bgcolor="#ffffff" class="section-padding" >

                            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                            <tbody><tr>
                                <td bgcolor="#ffffff" align="center" style="padding: 5px 0px 5px 0px;" class="section-padding">
                                    <table border="0" cellpadding="0" cellspacing="0" width="640" class="responsive-table" align="center">
                                    <tbody>


                                    <tr><!--MOVABLE INK-->
                                    <td>
                                        <table border="0" cellpadding="0" cellspacing="0" width="640" class="wrapper" bgcolor="#ffffff" align="center">
                                        <tbody><tr>
                                            <td style="padding: 15px 15px 5px 15px;">
                                                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                                <tbody>
                                                <tr>


                                                    <td valign="top" width="290" class="block_td" style="margin:0px auto;">

                                                        <table cellpadding="0" cellspacing="0" border="0" >
                                                             <tr>
                                                                <td align="left" style="font-family: Ariel, Arial, Helvetica, sans-serif; font-size: 22px; line-height: 26px; color:#002663;padding:0px 0px 25px 0px;" colspan="2">
                                                                    <b>Be Ready.</b>
                                                                </td>

                                                            </tr>
                                                                <td rowspan="3" valign="top" width="57" style="padding-right:10px;;">
                                                                    <img src="http://image.email-libertymutual.com/lib/fe6a15707464047f7c1c/m/1/CatAuto-Phone-35x73.jpg" width="35" height="73" alt="House getting hit by a fallen tree" border="0">
                                                                </td>
                                                                <td valign="top" align="left">
                                                                    <table cellpadding="0" cellspacing="0" border="0" style="padding: -5px 0px 0px 0px;">
                                                                        <tr>
                                                                            <td style="font-family:Arial, Helvetica, sans-serif; font-size:14px; color:#333333; line-height:17px; padding-left:0px;">
                                                                            <b>Download our app:</b>
                                                                            </td>
                                                                        </tr>
                                                                        <tr>
                                                                            <td valign="top" style="font-family:Arial, Helvetica, sans-serif;font-size:14px;line-height:17px;">
                                                                                <table cellpadding="2" cellspacing="2" border="0"> 
                                                                                    <tr>
                                                                                        <td style="valign="top">&bull;</td>
                                                                                        <td style="font-family:Arial, Helvetica, sans-serif;font-size:14px;line-height:17px;">Take pictures of damage</td>
                                                                                    </tr>
                                                                                    <tr>
                                                                                        <td valign="top">&bull;</td>
                                                                                        <td style="font-family:Arial, Helvetica, sans-serif;font-size:14px;line-height:17px;">Submit your claim</td>
                                                                                    </tr>

                                                                                </table>
                                                                            </td>
                                                                        </tr>
                                                                        <tr>
                                                                            <td style=" padding-top:2px;padding-bottom:35px;">
                                                                                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                                                                    <tbody><tr> 
                                                                                        <td class="mobile-hide">
                                                                                            <a href="http://www.movable-ink-7850.com/p/rp/aa8600496aa4ae32/url?MM_webID=%%WebID%%"><img src="http://www.movable-ink-7850.com/p/rp/aa8600496aa4ae32.png?MM_webID=%%WebID%%" alt="House getting hit by a fallen tree"></a>
                                                                                        </td>
                                                                                    </tr>
                                                                                    <tr>

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


                                                                            </td>                                      
                                                                        </tr>
                                                                        <tr>                                                            
                                                                            <td style="padding-right:35px;">
                                                                                <!--[if !mso 9]><!-->
                                                                                <div class="mobilecontent" style="mso-hide:all;display:none;max-height:0px;overflow:hidden;" align="center">
                                                                                    <a href="http://www.movable-ink-7850.com/p/rp/aa8600496aa4ae32/url?MM_webID=%%WebID%%"><img src="http://www.movable-ink-7850.com/p/rp/aa8600496aa4ae32.png?MM_webID=%%WebID%%" border="0" alt="House getting hit by a fallen tree"></a>                                                 
                                                                                </div>
                                                                                <!--<![endif]-->
                                                                            </td>
                                                                        </tr>
                                                                    </table>

                                                                </td>
                                                            </tr>
                                                        </table>
                                                    </td>
                                                    <td valign="top" width="290" class="block_td" style="margin:auto;">
                                                        <table cellpadding="0" cellspacing="0" border="0">
                                                            <tr>
                                                                <td style="font-family: Ariel, Arial, Helvetica, sans-serif; font-size: 22px; line-height: 26px; color:#002663;padding:0px 0px 25px 0px;" colspan="2">
                                                                    <b>Stay Organized.</b>
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td rowspan="3" valign="top" width="60" style="padding-right:10px;">
                                                                    <img src="http://image.email-libertymutual.com/lib/fe6a15707464047f7c1c/m/1/CatAuto-Icon-Devices-50x50.jpg" alt="" border="0">
                                                                </td>
                                                                <td valign="top" align="left">
                                                                    <table cellpadding="0" cellspacing="0" border="0" style="padding: -5px 0px 0px 0px;">
                                                                        <tr>
                                                                            <td style="font-family:Arial, Helvetica, sans-serif; font-size:14px; color:#333333; line-height:17px; padding-left:0px;">
                                                                            <b>Visit eService today:</b>
                                                                            </td>
                                                                        </tr>
                                                                        <tr>
                                                                            <td valign="top" style="font-family:Arial, Helvetica, sans-serif;font-size:14px;line-height:17px;">
                                                                                <table cellpadding="2" cellspacing="2" border="0"> 
                                                                                    <tr>
                                                                                        <td valign="top">&bull;</td>
                                                                                        <td style="font-family:Arial, Helvetica, sans-serif;font-size:14px;line-height:17px;"><span class="appleLinks2">24&#47;7 access</span></td>
                                                                                    </tr>
                                                                                    <tr>
                                                                                        <td valign="top">&bull;</td>
                                                                                        <td style="font-family:Arial, Helvetica, sans-serif;font-size:14px;line-height:17px;">Manage your policy online</td>
                                                                                    </tr>

                                                                                </table>
                                                                            </td>
                                                                        </tr>
                                                                        <tr>
                                                                            <td style="padding-top:2px;">
                                                                                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                                                                    <tbody><tr> 
                                                                                        <td class="mobile-hide">
                                                                                            <a href="https://www.libertymutual.com/home-insurance/home-coverages-and-benefits/home-insurance-benefits/property-replacement-service?MM_webID=%%WebID%%"><img src="http://image.email-libertymutual.com/lib/fe6a15707464047f7c1c/m/1/CatAuto-Button-Sign-In-70x19.jpg"></a>
                                                                                        </td>
                                                                                    </tr>
                                                                                    <tr>

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



                                                                            </td>                                      
                                                                        </tr>
                                                                        <tr>                                                            
                                                                            <td style="padding-top: 30px; padding-right:40px;">
                                                                                <!--[if !mso 9]><!-->
                                                                                <div class="mobilecontent" style="mso-hide:all;display:none;max-height:0px;overflow:hidden;" align="center">
                                                                                    <a href="https://www.libertymutual.com/home-insurance/home-coverages-and-benefits/home-insurance-benefits/property-replacement-service?MM_webID=%%WebID%%"><img src="http://image.email-libertymutual.com/lib/fe6a15707464047f7c1c/m/1/CatAuto-Button-Sign-In-139x38.jpg" width="139" height="38" border="0" alt="House getting hit by a fallen tree">                                                      
                                                                                </div>
                                                                                <!--<![endif]-->
                                                                            </td>
                                                                        </tr>
                                                                    </table>

                                                                </td>
                                                            </tr>
                                                        </table>
                                                    </td>
                                                </tr>
                                                </tbody></table>
                                            </td>
                                            </tr>
                                            <tr>
                                                <td style="padding: 15px 15px 20px 15px;" class="tdLine">
                                                    <table width="100%" align="center" cellpadding="0" cellspacing="0" class="tblLine">
                                                        <tr>
                                                            <td style="line-height:1px; font-size:1px; background-color:#f6f4f5" class="tdLineActual">&nbsp;</td>
                                                        </tr>                       
                                                    </table> <!-- tblLine -->
                                                </td> <!-- tdLine -->
                                            </tr>

                                        </tbody></table>


                                    </td>
                                    </tr><!--END OF MOVABLE INK-->





                                    </tbody></table>
                                </td>       
                            </tr>
                            </tbody></table>
                        </td>
                    </tr>
                    </tbody></table><!--END OF BODY-->





                </td>
                </tr>
                </table>
            </td>
            </tr>
            </table><!--END OF CONTAINER-->

            </body>
            </html>

1 个答案:

答案 0 :(得分:0)

但是我不建议使用嵌套表格,但为您的结构添加了一个表格以获得所需结果: demo

<table width="80%" border="0" align="center" cellspacing="0" cellpadding="0">
相关问题