mjml icon indicating copy to clipboard operation
mjml copied to clipboard

Equal height columns within a group

Open tpetry opened this issue 6 years ago • 39 comments

Problem description A common problem in email design (and web) design is to have content of the same height standing side by side. Content should be responsive in mails, but the mj-group tag allows you to prevent stacking if certain content should really be displayed side by side. This is a simple example of what we want to achieve: Bildschirmfoto 2019-04-19 um 11 05 18

There are many variations of this requirement, but in the end it is always about making two columns (mj-column) the same height for different aspects of styling (background colors, background images, common alignment lines, ...).

Possibilities to solve it currently Currently, the problem can only be solved by assigning the same fixed height to each column. This is feasible for one-time mailings created by a programmer/designer, but it's a very complex thing because the slightest text change requires new height values. Additionally it is not guaranteed that the height specification will work everywhere because the different operating systems render fonts slightly different and therefore different line breaks and text heights could occur.

The approach does not work at all with dynamically generated mails consisting of e.g. contents from a database.

Highlighting the current technical state The following MJML code creates the following mail with columns not of the same height:

<mjml>
  <mj-body background-color="#2980b9" width="610px">
    <mj-section background-color="#3498db" padding="5px">
      <mj-group>
        <mj-column background-color="#c0392b" width="50%">
          <mj-text>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam.</mj-text>
        </mj-column>
        <mj-column background-color="#e67e22" width="50%">
          <mj-text>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum.</mj-text>
        </mj-column>
      </mj-group>
    </mj-section>
  </mj-body>
</mjml>
Bildschirmfoto 2019-04-19 um 11 20 59

Why automatic columns of the same height are currently not possible Currently, mjml-column tags are rendered in the same way whether they are in a section or group. This happens because an AST is created based on the markup and each tag renders itself and only inserts the markup of the rendered child nodes in the correct places.

The resulting markup looks something like this:

<div mjml-group>
    <outlook-table>
        <outlook-row>
            [for every column in group]
                <outlook-colum width="together 100%">
                    <div mjml-column width="together 100%" />
                </outlook-colum>
            [/for every column in group]
        </outlook-row>
    <outlook-table>
</div>

In contrast to sections the columns do not stack because they are assigned a fixed width which together results in 100% width. The generated markup is absolutely useful because a column is always rendered the same way and only the parent (section or group) controls the width differently.

A common height is not possible because divs in a div (or table column) cannot be instructed to have the same height.

Possible solution to the problem The group renderer will not just render its markup and let the mjml-column renderer create the content. The Group Renderer will do the rendering of itself and its columns and will only handover rendering the contents of the columns to these child components.

Thus it is possible to create new markup for columns in a group and to render groups and columns simply as a table. It would look something like this:

<table mjml-group>
    <tr>
        [for every column in group]
            <td background color and images applied here width="together 100%">
                <markup to implement features like padding etc>
                    <child renders inserting the real content here>
                </markup>
            </td>
        [/for every column in group]
    </tr>
</table>

Addendum This feature is not only limited to people using the mjml markup language. It's not possible to do it in mailjets visual builder too which is based on mjml: Bildschirmfoto 2019-04-19 um 12 15 43

tpetry avatar Apr 19 '19 10:04 tpetry

Interesting, equal-height columns are always a problem because of responsiveness, but in a mj-group it may be possible to do something. Might not be an easy one though

kmcb777 avatar Apr 26 '19 16:04 kmcb777

The markup will be really easy and i will not expect any problems with client as you can use plain old HTML 1.0 tables. But i was not able yet to build a PoC because i didn't succeed in changing the markup generation of the mjml group renderer.

tpetry avatar Apr 29 '19 08:04 tpetry

Any news on this? I am having the same problem as described by @tpetry with dynamically content from a database.

Cool-and-Deadly avatar Nov 09 '19 02:11 Cool-and-Deadly

I have the same problem.

NEALON avatar Jan 01 '20 13:01 NEALON

me too, would love to see this resolved in the next version

brunocfalcao avatar Jan 11 '20 22:01 brunocfalcao

Already thought this would be implemented. Hopefully, it's added in a new release!

addisontaylor avatar Feb 05 '20 14:02 addisontaylor

Yeah we would like to do so for mobile only, but it's a bit hard to tweak current group+column code to have this working without breaking everything else. Maybe this could be implemented in a custom comp for now and merge it into both group/column if we can.

iRyusa avatar Feb 05 '20 14:02 iRyusa

This would be so useful!

jakemcallister avatar May 24 '20 16:05 jakemcallister

@iRyusa @DRoet any updates?

iameduardod avatar Jun 17 '20 17:06 iameduardod

I have the same problem. Is there any update on it? @iRyusa @DRoet

sanazmemar avatar Oct 07 '20 16:10 sanazmemar

I'm also waiting for something like this

codepen.io/gurovdmitriy/pen

Screenshot_2

GurovDmitriy avatar Nov 08 '20 17:11 GurovDmitriy

Bump this

samueljim avatar Aug 05 '21 01:08 samueljim

bump

azyskowski avatar Sep 16 '21 11:09 azyskowski

@iRyusa Are there any updates on this issue ?

ajay47 avatar Sep 24 '21 07:09 ajay47

@iRyusa Есть ли обновления по этому поводу?

I have been working with vue-style structured mjml assembly on gulp for a long time. And I just collect used components for myself. It's easier to write such things yourself. If someone volunteered to do the work together, then we could register some nice custom components ...

GurovDmitriy avatar Sep 24 '21 07:09 GurovDmitriy

We're not currently working on this

iRyusa avatar Sep 24 '21 07:09 iRyusa

  • desired feature

shestakov-vladyslav avatar Mar 10 '22 13:03 shestakov-vladyslav

Bump

lucswart avatar Apr 15 '22 07:04 lucswart

Desired feature +1

webuxr avatar Apr 27 '22 20:04 webuxr

+1

witalijx avatar Jun 10 '22 16:06 witalijx

+1

automatyzuj avatar Jun 13 '22 22:06 automatyzuj

desired feature please add this

bekdauletarynbek avatar Jul 09 '22 05:07 bekdauletarynbek

Yes this is very desired feature. I need this! :)

kamilus67 avatar Jul 25 '22 09:07 kamilus67

This is a desired feature!

karrabl4st avatar Aug 02 '22 15:08 karrabl4st

Update on this?

imcodingideas avatar Aug 31 '22 01:08 imcodingideas

Update?

kehers avatar Nov 15 '22 08:11 kehers

Still a desired feature, it's simple to do with a html table but it'd be nice to have it directly in MJML

JackBailey avatar Jan 11 '23 16:01 JackBailey

Bump for a desired feature.

CTownsdin avatar Mar 02 '23 22:03 CTownsdin

Any update?

cebreus avatar May 27 '23 11:05 cebreus

+1

EvilaMany avatar Jun 13 '23 16:06 EvilaMany

Add me to the list of folks struggling with this issue.

cbrooks86 avatar Jun 14 '23 11:06 cbrooks86