question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

mj-column gets vertically stacked on gmail, on desktop.

See original GitHub issue

Describe the bug mj-column gets vertically stacked on gmail, in both desktop & mobile

To Reproduce Steps to reproduce the behavior:

  1. Create a file with this MJML code: <mjml><mj-body><mj-section><mj-column><mj-text>Hello</mj-text></mj-column><mj-column><mj-text>World</mj-text></mj-column></mj-section></mj-body></mjml>
  2. Convert it to html using mjml 4.2.0, running on a node, express server.
  3. Send the HTML to an email address.
  4. See error

Expected behavior mj-column should not vertically stack on desktop.

MJML environment (please complete the following information):

  • OS: Ubuntu
  • MJML Version: 4.2.0
  • MJML tool used: mjml on node and express

Affected email clients (for rendering issues):

  • Email Client: Gmail
  • Browser Google Chrome

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
anmdotdevcommented, Oct 17, 2018

With some intensive testing, I figured out there is probably a css inliner that is causing the issue at one syntax.

@-ms-viewport {
     width: 320px;
}

@viewport {
      width: 320px;
}

When I removed this above code from the generated html, it worked fine even with my server.

It seems like @viewport is something which is not supported by the inliner.

Try removing the above piece of code from the generated html to see if it works

1reaction
anmdotdevcommented, Oct 11, 2018

After a bit of research, I came across this. https://stackoverflow.com/questions/46856100/why-is-gmail-ignoring-my-media-queries-on-ios

So what this suggests is that, basically Gmail will only read the first media query.

So I checked the HTML generated by the above MJML Code. It had two media queries in the document:

<style type="text/css">
        @media only screen and (max-width:480px) {
            @-ms-viewport {
                width: 320px;
            }

            @viewport {
                width: 320px;
            }
        }
</style>

<style type="text/css">
        @media only screen and (min-width:480px) {
            .mj-column-per-50 {
                width: 50% !important;
                max-width: 50%;
            }
        }
</style>

I modified the HTML to contain only one, i.e.

<style type="text/css">
        @media only screen and (min-width:480px) {
            .mj-column-per-50 {
                width: 50% !important;
                max-width: 50%;
            }
        }
</style>

And It Worked! The columns are not stacking anymore.

Also, for some reason, when I select the move to inline option at putsmail, the columns dont work and they get stacked.

Now how did it work with Putsmail before? May be it combines both the style tags, into one. I am not sure.

So I do think this is indeed an MJML issue, and maybe we should reopen this. What do you think?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Compatibility for mj-column - MJML
1Columns are stacked by default, so they appear properly on mobile devices. However, because columns rely on media queries, they do not work ......
Read more >
Gmail App: Stacked Column Width Woes (No Media Queries)
We have 1, 2 and 3 column stacks, all of which end up different widths when stacked because max-width has to be set...
Read more >
Get Started with MJML: How to Code Responsive Emails
Discover a simple way to develop responsive emails. Find out how to get started with the MJML framework and code mobile-friendly campaigns.
Read more >
MJML Not outputting correctly in outlook - Stack Overflow
... padding-bottom="0px" padding-top="0"> <mj-column vertical-align="top" width="100%"> ... This renders perfectly in outlook web and gmail.
Read more >
MJML Examples to Get You Started - Scalero
Download the MJML app – this is basically an MJML desktop app, so you'll be able ... It's important to nest the <mj-column>...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found