Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mobile/Desktop Hide #770

Closed
jamiefinlayson opened this issue Aug 3, 2017 · 12 comments
Closed

Mobile/Desktop Hide #770

jamiefinlayson opened this issue Aug 3, 2017 · 12 comments

Comments

@jamiefinlayson
Copy link

jamiefinlayson commented Aug 3, 2017

Is there support for hiding/revealing content blocks on mobile/desktop, taking into account Outlook, Gmail and Android?

@Renjaminino
Copy link

Renjaminino commented Aug 3, 2017

If I am understanding correctly, you shouldn't have to do that in the compiled HTML, unless it's something very customized.

You could write something like this below in your mj-style tag within the mj-head:

@media only screen and (max-width: 480px) { *[class~=hide_on_mobile] { display: none !important;} }

And then inline, you would write:

<mj-column css-class="hide_on_mobile"> <mj-image src="http://www.google.com/google.png" padding="0" /> </mj-column>

I've done LITMUS testing on that simple snippet above, and it works on everything Outlook 2007+ without any extra post MJML injections.

Futhermore, you can then create another media query to block anything on desktop, by switching the min and max values around, and voila.

Does that help?

@jamiefinlayson
Copy link
Author

jamiefinlayson commented Aug 3, 2017 via email

@Renjaminino
Copy link

OH, I see. I've done tests on gmail, and it works fine using this. :)

@jamiefinlayson
Copy link
Author

jamiefinlayson commented Aug 3, 2017 via email

@Renjaminino
Copy link

Not my app, but thank you either way. 👍 - Sure love using it.

@iRyusa
Copy link
Member

iRyusa commented Aug 7, 2017

Hi here !

Following up on @Renjaminino answer, you should add media queries on desktop version instead of mobile. Most of mobile client doesn't support media queries.
And you can use a class selector instead of attribute selectors, some clients doesn't support it

So :

@media only screen and (max-width: 480px) { *[class~=hide_on_mobile] { display: none !important;} }

becomes :

.hide_on_mobile { display: none !important;}
@media only screen and (min-width: 480px) { .hide_on_mobile { display: block !important;} }

@iRyusa iRyusa closed this as completed Aug 7, 2017
@jamiefinlayson
Copy link
Author

jamiefinlayson commented Aug 7, 2017 via email

@Renjaminino
Copy link

@iRyusa - thanks for the clarification. I wasn't aware of that fix. Much appreciated.

@jamiefinlayson
Copy link
Author

jamiefinlayson commented Aug 8, 2017 via email

@iRyusa
Copy link
Member

iRyusa commented Aug 8, 2017

Well, it's just me, but I don't really like to have duplicate content in my email, because some clients could display both, but if it works for you then 👍

@Renjaminino
Copy link

Renjaminino commented Aug 8, 2017

I agree with @iRyusa, and trust me @jamiefinlayson, I totally understand the frustrations with client compatibility, on mobile specifically.

For me personally...on top of having the mailers work as best as possible on major platforms, you'll always have 1 or 2, or even 3 outliers. And honestly...that's okay, unless you're trying to find that magic unicorn, which is do-able, but difficult.

My only problem with your code above, and mind you this is entirely subjective on my end is this:
My company uses Pardot/Salesforce, to manage e-mail campaigns. As an added stressful bonus, I code my e-mails then need to enable certain parts in the compiled html to be editable for our marketing department to edit, remove/add components. The option of having desktop/mobile, versions of the same content is not possible in my scenario.

:)

@jamiefinlayson
Copy link
Author

jamiefinlayson commented Aug 8, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants