mjmlio / mjml

MJML: the only framework that makes responsive-email easy
https://mjml.io
MIT License
17.08k stars 960 forks source link

Column with vertical-align:middle only works if highest column has va:middle #1931

Closed YasiOnFire closed 4 years ago

YasiOnFire commented 4 years ago

Describe the bug Vertical-align: middle on a column, only works if the tallest column in a row, also has vertical-align set to middle.

To Reproduce Steps to reproduce the behavior:

  1. Rnder this code:
    <mjml>
    <mj-body>
    <mj-section>
      <mj-column vertical-align="bottom">
        <mj-text>
          Lorem
        </mj-text>
      </mj-column>
      <mj-column vertical-align="middle">
        <mj-text>
          lorem<br>ipsum
        </mj-text>
      </mj-column>
      <mj-column vertical-align="top">
        <mj-text>
          Lorem ipsum dolor sit amet
        </mj-text>
      </mj-column>
      <mj-column vertical-align="top">
        <mj-text>
          lorem<br>ipsum<br>dolor<br>sit<br>amet<br>consecteur
        </mj-text>
      </mj-column>
    </mj-section>
    </mj-body>
    </mjml>
  2. The second column has vertical-align set to middle. This will not work unless the last column (which is the tallest) also has vertical-align set to middle.

Expected behavior Column with vertical-align:middle to be vertically centered no matter what the tallest column va setting is.

MJML environment (please complete the following information):

Screenshots Adnotacja 2020-06-01 131726

Adnotacja 2020-06-01 131813

iRyusa commented 4 years ago

Well that's not really related to MJML because it's actually how vertical align works in CSS.

YasiOnFire commented 4 years ago

Are you sure about this? I've made some examples: https://jsfiddle.net/Yasio/pns4tbxh/12/

iRyusa commented 4 years ago

Those examples aren't really related to MJML usage of vertical align. vertical align must be set on all column to be effective within this setup (and mostly middle doesn't work properly if set on only one column but bottom & top works fine).

There's multiple article that describe how vertical-align works, and it's one of the most ambiguous css attribute as it works "relative" to other nodes.

YasiOnFire commented 4 years ago

Ok, I understand. Thank You. I've made a "not so elegant" "fix" that works in my case. If any one stumbles upon this, try adding this style

<mj-head>
    <mj-style>
      @media screen and (min-width:480px) {
        .vam-fix [class^="mj-column-"] {
          display: table-cell !important;
        }
      }
    </mj-style>
  </mj-head>

and then add css-class="vam-fix" on a section with vartical-allign middle on one element.

iRyusa commented 4 years ago

That could have some major issues on some email clients so I wouldn't advise it.