Mady
Mady3mo ago

centered vs left aligned text

I'm using mo.md to add text to my notebook. Is there a way to control the alignment? It seemed like it was automatically centered earlier, but now it's left aligned.
Solution:
Yea - I think we wrap those in too many elements. You might want to do “<h1 style=“text-align:center”> header… “
Jump to solution
11 Replies
Myles Scolnick
Myles Scolnick3mo ago
when width is maxed out (full) we default the heading to the left side as we think it looks better for super wide screens (keeps content together) you can do mo.md().left() , mo.md().right(), mo.md().center() all UI elements should have left/right/center too
Mady
MadyOP3mo ago
This worked, thank you very much! Actually, maybe not? It's working on desktop but not mobile.
Myles Scolnick
Myles Scolnick3mo ago
that seems odd what about on desktop if you squish the screen this also most the content left/right/middle, but doesnt change the text to by "aligned" left/right/middle per https://developer.mozilla.org/en-US/docs/Web/CSS/text-align you could maybe use styles, mo.md().center()style({"text-align": "center"})
Mady
MadyOP3mo ago
Can you only style one line at a time? The text is two different lines, and it worked on the second one but not the first.
No description
Mady
MadyOP3mo ago
I split it out into two different cells and it seems like .style() still doesn't do it for the header.
Solution
Myles Scolnick
Myles Scolnick3mo ago
Yea - I think we wrap those in too many elements. You might want to do “<h1 style=“text-align:center”> header… “
Mady
MadyOP3mo ago
am I not doing this right? this definitely isn't H1
No description
Myles Scolnick
Myles Scolnick3mo ago
Try mo.md? I don’t think we style any HTML by default. It all gets reset Off topic: but it’s generally common to “reset” all defaults of html elements since they are different cross-browser. We may only style markdown and not plain html (that is left as-is)
Mady
MadyOP3mo ago
this is what I have now and it still doesn't center on mobile
No description
Myles Scolnick
Myles Scolnick3mo ago
Sorry, it’s text-align:center I had an original typo
Mady
MadyOP3mo ago
That did it, I should've noticed that. As always, thank you!