Многострочные текстовые значения разрушают горизонтальное выравнивание макета - PullRequest
0 голосов
/ 11 сентября 2018

В следующем коде, когда значение первого столбца превышает одну строку (в этом случае элемент с заголовком « длинное значение, превышающее одну строку »), столбец больше не выравниваетсяс двумя другими: enter image description here

<table>
      <tr >
        <td valign="top" style="padding: 17px 19px 0; background-color: #ffffff; text-align: center;" >
          <table border="0" role="presentation" cellpadding="0" cellspacing="0" width="100%" style="border:0 !important;" align="center">
            <tr>
              <td width="100%" align="center" style="padding: 17px 0 0;">
                <h2 style="margin: 0; font-family: 'Playfair Display', Georgia, serif; font-style: italic; font-size: 25px; color: #E35E19; font-weight: 900;">Coming soon</h2>
              </td>
            </tr>
          </table>
        </td>
      </tr>
      <!-- 3 Even Columns : BEGIN -->
      <tr>
        <td valign="top" style="padding: 0 19px 17px; background-color: #ffffff; text-align: center;">
          <table border="0" role="presentation" cellpadding="0" cellspacing="0" width="100%" style="border:0 !important;">
            <tr>
              <!-- Column : BEGIN -->
              <td width="33.33%">
                <table  cellspacing="0" cellpadding="0" border="0">
                  <tr>
                    <td  style="padding: 22px 11px 0px; text-align: center" >
                      <img src="http://placehold.it/170" width="163" height="163" alt="alt_text" border="0" class="fluid img221" style="vertical-align: middle; height: auto; background: #dddddd; font-family: sans-serif; font-size: 15px; color: #555555;">
                        </td>
                  </tr>
                  <tr>
                    <td  style="line-height: 20px; color: #000000; padding: 0; text-align: center;">
                      <p style="margin: 0; font-family: 'Roboto', Tahoma, sans-serif; font-size: 13px; line-height: 18px; font-weight: 700;">a long value that exceeds one line</p>
                      <p style="margin: 0; font-family: 'Roboto', Tahoma, sans-serif; font-size: 12px; line-height: 18px;"><i>Lorem ipsum</i></p>
                    </td>
                  </tr>
                </table>
              </td>
              <!-- Column : END -->
              <!-- Column : BEGIN -->
              <td width="33.33%">
                <table  cellspacing="0" cellpadding="0" border="0">
                  <tr>
                    <td  style="padding: 22px 11px 0px; text-align: center" >
                      <img src="http://placehold.it/170" width="163" height="163" alt="alt_text" border="0" class="fluid img221" style="vertical-align: middle; height: auto; background: #dddddd; font-family: sans-serif; font-size: 15px; color: #555555;">
                        </td>
                  </tr>
                  <tr>
                    <td  style="line-height: 20px; color: #000000; padding: 0; text-align: center;">
                      <p style="margin: 0; font-family: 'Roboto', Tahoma, sans-serif; font-size: 13px; line-height: 18px; font-weight: 700;">Lorem ipsum</p>
                      <p style="margin: 0; font-family: 'Roboto', Tahoma, sans-serif; font-size: 12px; line-height: 18px;"><i>Lorem ipsum</i></p>
                    </td>
                  </tr>
                </table>
              </td>
              <!-- Column : END -->
              <!-- Column : BEGIN -->
              <td width="33.33%">
                <table  cellspacing="0" cellpadding="0" border="0">
                  <tr>
                    <td  style="padding: 22px 11px 0px; text-align: center" >
                      <img src="http://placehold.it/170" width="163" height="163" alt="alt_text" border="0" class="fluid img221" style="vertical-align: middle; height: auto; background: #dddddd; font-family: sans-serif; font-size: 15px; color: #555555;">
                        </td>
                  </tr>
                  <tr>
                    <td  style="line-height: 20px; color: #000000; padding: 0; text-align: center;">
                      <p style="margin: 0; font-family: 'Roboto', Tahoma, sans-serif; font-size: 13px; line-height: 18px; font-weight: 700;">Lorem ipsum</p>
                      <p style="margin: 0; font-family: 'Roboto', Tahoma, sans-serif; font-size: 12px; line-height: 18px;"><i>Lorem ipsum</i></p>
                    </td>
                  </tr>
                </table>
              </td>
              <!-- Column : END -->
            </tr>
          </table>
        </td>
      </tr>
    </table>

Я удалил код ненужных тегов.Код, как показано выше, находится в отдельном файле и в настоящее время не является отдельным фрагментом.

Ответы [ 2 ]

0 голосов
/ 11 сентября 2018

Вы должны поместить еще один valign='top' во вложенную таблицу:

JSFIDDLE

...
<tr valign='top'>
              <!-- Column : BEGIN -->
...

Полный код:

<table>
      <tr >
        <td valign="top" style="padding: 17px 19px 0; background-color: #ffffff; text-align: center;" >
          <table border="0" role="presentation" cellpadding="0" cellspacing="0" width="100%" style="border:0 !important;" align="center">
            <tr>
              <td width="100%" align="center" style="padding: 17px 0 0;">
                <h2 style="margin: 0; font-family: 'Playfair Display', Georgia, serif; font-style: italic; font-size: 25px; color: #E35E19; font-weight: 900;">Coming soon</h2>
              </td>
            </tr>
          </table>
        </td>
      </tr>
      <!-- 3 Even Columns : BEGIN -->
      <tr>
        <td valign="top" style="padding: 0 19px 17px; background-color: #ffffff; text-align: center;">
          <table border="0" role="presentation" cellpadding="0" cellspacing="0" width="100%" style="border:0 !important;">
            <tr valign='top'>
              <!-- Column : BEGIN -->
              <td width="33.33%">
                <table  cellspacing="0" cellpadding="0" border="0">
                  <tr>
                    <td  style="padding: 22px 11px 0px; text-align: center" >
                      <img src="http://placehold.it/170" width="163" height="163" alt="alt_text" border="0" class="fluid img221" style="vertical-align: middle; height: auto; background: #dddddd; font-family: sans-serif; font-size: 15px; color: #555555;">
                        </td>
                  </tr>
                  <tr>
                    <td  style="line-height: 20px; color: #000000; padding: 0; text-align: center;">
                      <p style="margin: 0; font-family: 'Roboto', Tahoma, sans-serif; font-size: 13px; line-height: 18px; font-weight: 700;">a long value that exceeds one line</p>
                      <p style="margin: 0; font-family: 'Roboto', Tahoma, sans-serif; font-size: 12px; line-height: 18px;"><i>Lorem ipsum</i></p>
                    </td>
                  </tr>
                </table>
              </td>
              <!-- Column : END -->
              <!-- Column : BEGIN -->
              <td width="33.33%">
                <table  cellspacing="0" cellpadding="0" border="0">
                  <tr>
                    <td  style="padding: 22px 11px 0px; text-align: center" >
                      <img src="http://placehold.it/170" width="163" height="163" alt="alt_text" border="0" class="fluid img221" style="vertical-align: middle; height: auto; background: #dddddd; font-family: sans-serif; font-size: 15px; color: #555555;">
                        </td>
                  </tr>
                  <tr>
                    <td  style="line-height: 20px; color: #000000; padding: 0; text-align: center;">
                      <p style="margin: 0; font-family: 'Roboto', Tahoma, sans-serif; font-size: 13px; line-height: 18px; font-weight: 700;">Lorem ipsum</p>
                      <p style="margin: 0; font-family: 'Roboto', Tahoma, sans-serif; font-size: 12px; line-height: 18px;"><i>Lorem ipsum</i></p>
                    </td>
                  </tr>
                </table>
              </td>
              <!-- Column : END -->
              <!-- Column : BEGIN -->
              <td width="33.33%">
                <table  cellspacing="0" cellpadding="0" border="0">
                  <tr>
                    <td  style="padding: 22px 11px 0px; text-align: center" >
                      <img src="http://placehold.it/170" width="163" height="163" alt="alt_text" border="0" class="fluid img221" style="vertical-align: middle; height: auto; background: #dddddd; font-family: sans-serif; font-size: 15px; color: #555555;">
                        </td>
                  </tr>
                  <tr>
                    <td  style="line-height: 20px; color: #000000; padding: 0; text-align: center;">
                      <p style="margin: 0; font-family: 'Roboto', Tahoma, sans-serif; font-size: 13px; line-height: 18px; font-weight: 700;">Lorem ipsum</p>
                      <p style="margin: 0; font-family: 'Roboto', Tahoma, sans-serif; font-size: 12px; line-height: 18px;"><i>Lorem ipsum</i></p>
                    </td>
                  </tr>
                </table>
              </td>
              <!-- Column : END -->
            </tr>
          </table>
        </td>
      </tr>
    </table>
0 голосов
/ 11 сентября 2018

Вертикальное выравнивание по умолчанию - центр, но вы хотите верх:

tr {
    vertical-align: top;
}
<table>
      <tr >
        <td valign="top" style="padding: 17px 19px 0; background-color: #ffffff; text-align: center;" >
          <table border="0" role="presentation" cellpadding="0" cellspacing="0" width="100%" style="border:0 !important;" align="center">
            <tr>
              <td width="100%" align="center" style="padding: 17px 0 0;">
                <h2 style="margin: 0; font-family: 'Playfair Display', Georgia, serif; font-style: italic; font-size: 25px; color: #E35E19; font-weight: 900;">Coming soon</h2>
              </td>
            </tr>
          </table>
        </td>
      </tr>
      <!-- 3 Even Columns : BEGIN -->
      <tr>
        <td valign="top" style="padding: 0 19px 17px; background-color: #ffffff; text-align: center;">
          <table border="0" role="presentation" cellpadding="0" cellspacing="0" width="100%" style="border:0 !important;">
            <tr>
              <!-- Column : BEGIN -->
              <td width="33.33%">
                <table  cellspacing="0" cellpadding="0" border="0">
                  <tr>
                    <td  style="padding: 22px 11px 0px; text-align: center" >
                      <img src="http://placehold.it/170" width="163" height="163" alt="alt_text" border="0" class="fluid img221" style="vertical-align: middle; height: auto; background: #dddddd; font-family: sans-serif; font-size: 15px; color: #555555;">
                        </td>
                  </tr>
                  <tr>
                    <td  style="line-height: 20px; color: #000000; padding: 0; text-align: center;">
                      <p style="margin: 0; font-family: 'Roboto', Tahoma, sans-serif; font-size: 13px; line-height: 18px; font-weight: 700;">a long value that exceeds one line</p>
                      <p style="margin: 0; font-family: 'Roboto', Tahoma, sans-serif; font-size: 12px; line-height: 18px;"><i>Lorem ipsum</i></p>
                    </td>
                  </tr>
                </table>
              </td>
              <!-- Column : END -->
              <!-- Column : BEGIN -->
              <td width="33.33%">
                <table  cellspacing="0" cellpadding="0" border="0">
                  <tr>
                    <td  style="padding: 22px 11px 0px; text-align: center" >
                      <img src="http://placehold.it/170" width="163" height="163" alt="alt_text" border="0" class="fluid img221" style="vertical-align: middle; height: auto; background: #dddddd; font-family: sans-serif; font-size: 15px; color: #555555;">
                        </td>
                  </tr>
                  <tr>
                    <td  style="line-height: 20px; color: #000000; padding: 0; text-align: center;">
                      <p style="margin: 0; font-family: 'Roboto', Tahoma, sans-serif; font-size: 13px; line-height: 18px; font-weight: 700;">Lorem ipsum</p>
                      <p style="margin: 0; font-family: 'Roboto', Tahoma, sans-serif; font-size: 12px; line-height: 18px;"><i>Lorem ipsum</i></p>
                    </td>
                  </tr>
                </table>
              </td>
              <!-- Column : END -->
              <!-- Column : BEGIN -->
              <td width="33.33%">
                <table  cellspacing="0" cellpadding="0" border="0">
                  <tr>
                    <td  style="padding: 22px 11px 0px; text-align: center" >
                      <img src="http://placehold.it/170" width="163" height="163" alt="alt_text" border="0" class="fluid img221" style="vertical-align: middle; height: auto; background: #dddddd; font-family: sans-serif; font-size: 15px; color: #555555;">
                        </td>
                  </tr>
                  <tr>
                    <td  style="line-height: 20px; color: #000000; padding: 0; text-align: center;">
                      <p style="margin: 0; font-family: 'Roboto', Tahoma, sans-serif; font-size: 13px; line-height: 18px; font-weight: 700;">Lorem ipsum</p>
                      <p style="margin: 0; font-family: 'Roboto', Tahoma, sans-serif; font-size: 12px; line-height: 18px;"><i>Lorem ipsum</i></p>
                    </td>
                  </tr>
                </table>
              </td>
              <!-- Column : END -->
            </tr>
          </table>
        </td>
      </tr>
    </table>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...