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.

Responsive text alignment

See original GitHub issue

I frequently build layouts where I’d like to change the text alignment based on breakpoint. For example, I’ll have two columns on desktop: image in the left column, left-aligned text in the right column. On mobile, when the columns stack vertically, I’d like to center the text instead of keeping it left-aligned.

As far as I can tell, there’s no way to do this because the align property of <mj-text> applies to both breakpoints.

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
ngarniercommented, Jul 19, 2018

A simple media query will help you do that: https://mjml.io/try-it-live/rJ17Da6mX

Note that it’s better to use the default styles for the mobile layout (center), and then use a media query for the responsive behaviour on desktop (media queries are better supported in desktop clients).

0reactions
Gwixcommented, Nov 22, 2019

I might have a solution for that problem, it still needs to be tested all-around, but… If you declare, in your mj-all tag in mj-head, that default align for everything is “none”, rather than left/center/right (or omitting to declare which results in align=“center”), you might end up with an argument error in your HTML, but it surely can be overridden by inline styling and media queries. <td align="none"> I hope it’s gonna pass the final tests. But for now, M$ LookOut and Gmail are okay!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Change text-align responsively (with Bootstrap 3)?
Although the provided solution is absolutely right, I think there is a different approach that could be interesting. Bootstrap does not provide alignment...
Read more >
Responsive Text Align - CodePen
An unusual celestial object called CX330 was first detected as a source of X-ray light in 2009. It has been launching “jets” of...
Read more >
CSS Text Alignment and Text Direction - W3Schools
The text-align property is used to set the horizontal alignment of a text. A text can be left or right aligned, centered, or...
Read more >
Live Demo: Bootstrap Responsive Text Alignment
Text will be center aligned on extra-large sized (xl) viewports and up. Note: Open the output in a new blank tab (Click the...
Read more >
Bootstrap 4 Responsive Alignment on Codeply
Example of the new reponsive floats and text alignment for Bootstrap 4. Now you can align differently at different widths. Pull right only...
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