2017-01-25 1 views
-1

Мне нужно создать отзывчивое электронное письмо с основой основания, где цвет идет по всей ширине (например, пример оболочки) и текст центрирован (например, пример контейнера). Я застреваю, потому что, если я использую класс оболочки, текст летел влево, и я не могу центрировать текст. Если я использую контейнер, я не могу заставить цвет идти по полной ширине, но текст центрирован. Существует около 10 строк, и каждая строка имеет другой цвет.Wrapper и container do different layout

The layout

С обертке:

Wrapper Example

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
    <meta name="viewport" content="width=device-width" /> 
    <title>Title</title> 
    <link rel="stylesheet" href="css/foundation-emails.css" /> 
</head> 

<body> 
    <table align="center" class="wrapper"> 
    <tbody> 
     <tr> 
     <td> 
      <table class="row"> 
      <tbody> 
       <tr> 
       <th class="small-12 large-12 columns first last" style="background-color: red;"> 
        <table> 
        <tr> 
         <th>This is a column. Columns contain your content.</th> 
         <th class="expander"></th> 
        </tr> 
        </table> 
       </th> 
       </tr> 
      </tbody> 
      </table> 
     </td> 
     </tr> 
    </tbody> 
</table> 
</body> 
</html> 

с контейнером Container Example

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
    <meta name="viewport" content="width=device-width" /> 
    <title>Title</title> 
    <link rel="stylesheet" href="css/foundation-emails.css" /> 
</head> 

<body> 
    <table align="center" class="container"> 
    <tbody> 
     <tr> 
     <td> 
      <table class="row"> 
      <tbody> 
       <tr> 
       <th class="small-12 large-12 columns first last" style="background-color: red;"> 
        <table> 
        <tr> 
         <th>This is a column. Columns contain your content.</th> 
         <th class="expander"></th> 
        </tr> 
        </table> 
       </th> 
       </tr> 
      </tbody> 
      </table> 
     </td> 
     </tr> 
    </tbody> 
</table> 
</body> 
</html> 
+0

обещания, что вы потеряете свою работу, если доброволец не мчится, чтобы помочь вам эмоциональный шантаж худших, и совершенно неприемлемо здесь. Я рассмотрел это прошение [в этом мета-ответе] (http://meta.stackoverflow.com/a/326576/472495). – halfer

ответ

0

Вы можете просто переместить стиль background-color на кузов, вместо того чтобы иметь его на th и дать table.container прозрачный фон. Будет ли это работать?

@import url(https://cdnjs.cloudflare.com/ajax/libs/foundation-emails/2.2.1/foundation-emails.min.css)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml"> 
 
    <head> 
 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
 
    <meta name="viewport" content="width=device-width" /> 
 
    <title>Title</title> 
 
    <link rel="stylesheet" href="css/foundation-emails.css" /> 
 
    </head> 
 

 
    <body> 
 
    <div style="background-color: red;"> 
 
     <table align="center" class="container" style="background-color: transparent;"> 
 
     <tbody> 
 
      <tr> 
 
      <td> 
 
       <table class="row"> 
 
       <tbody> 
 
        <tr> 
 
        <th class="small-12 large-12 columns first last"> 
 
         <table> 
 
         <tr> 
 
          <th>This is a column. Columns contain your content. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</th> 
 
          <th class="expander"></th> 
 
         </tr> 
 
         </table> 
 
        </th> 
 
        </tr> 
 
       </tbody> 
 
       </table> 
 
      </td> 
 
      </tr> 
 
     </tbody> 
 
     </table> 
 
    </div> 
 
    <div style="background-color: green;"> 
 
     <table align="center" class="container" style="background-color: transparent;"> 
 
     <tbody> 
 
      <tr> 
 
      <td> 
 
       <table class="row"> 
 
       <tbody> 
 
        <tr> 
 
        <th class="small-12 large-12 columns first last"> 
 
         <table> 
 
         <tr> 
 
          <th>This is a column. Columns contain your content. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</th> 
 
          <th class="expander"></th> 
 
         </tr> 
 
         </table> 
 
        </th> 
 
        </tr> 
 
       </tbody> 
 
       </table> 
 
      </td> 
 
      </tr> 
 
     </tbody> 
 
     </table> 
 
    </div> 
 
    </body> 
 
</html>

EDIT:

Вот рабочая версия с отзывчивостью на основе того, что я мог кусочки из рамок.

@import url(https://cdnjs.cloudflare.com/ajax/libs/foundation-emails/2.2.1/foundation-emails.min.css)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml"> 
 
    <head> 
 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
 
    <meta name="viewport" content="width=device-width" /> 
 
    <title>Title</title> 
 
    <link rel="stylesheet" href="css/foundation-emails.css" /> 
 
    </head> 
 

 
    <body> 
 
    <table class="body"> 
 
     <tbody><tr> 
 
     <td class="center" align="center" valign="top"> 
 
      <table align="center" class="wrapper header float-center" style="background-color:red"><tbody><tr><td class="wrapper-inner"> 
 
      <table align="center" class="container" style="background-color:transparent"><tbody><tr><td> 
 

 
       <!-- single column row --> 
 
       <table class="row collapse"><tbody><tr> 
 
       <th>This is a column. Columns contain your content. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</th> 
 
       </tr></tbody></table> 
 
       
 
      </td></tr></tbody></table> 
 
      </td></tr></tbody></table> 
 
      <table align="center" class="wrapper header float-center" style="background-color:green"><tbody><tr><td class="wrapper-inner"> 
 
      <table align="center" class="container" style="background-color:transparent"><tbody><tr><td> 
 

 
       <!-- two column row --> 
 
       <table class="row collapse"><tbody><tr> 
 
       <th class="small-6 large-6 columns first"><table><tbody><tr><th> 
 
        <p>BASIC</p> 
 
        </th></tr></tbody></table></th> 
 
       <th class="small-6 large-6 columns last"><table><tbody><tr><th> 
 
        <p>BASIC</p> 
 
        </th></tr></tbody></table></th> 
 
       </tr></tbody></table> 
 

 
      </td></tr></tbody></table> 
 
      </td></tr></tbody></table> 
 
     </td> 
 
     </tr></tbody> 
 
    </table> 
 
    </body> 
 
</html>

+0

Большое спасибо за ответ. Проблема в том, что каждая строка имеет другой цвет, такой как моя фотография. Поэтому я не могу установить его на теле. – McDuck4

+0

@ McDuck4 Теоретически, если все, что вы делаете, меняет цвет, тогда должна работать простая обертка div с упаковкой цвета, в которой каждый контейнер должен работать. Это зависит от того, как должен выглядеть конечный результат. Я отредактировал свой ответ. –

+0

Omg да это работает. Но нормально ли иметь тег div в электронном письме? – McDuck4