Jump to content

How to center a text block on mobile only

Recommended Posts

Hi, 

I'm looking for a CSS code to change alignment on text block in mobile ONLY. 

Preferably center, but also would love the codes for left / right. 

Need it on a lot of blocks but as an example: 

homepage text block on mobile: 

#block-ed20e2002a61eaf311bb

password: smoothie123

 

I tried this CSS but it is not working:

@media screen and (max-width:767px) {

#enter-block-id-here>div {

text-align: center !important;

}

}

image.png

Link to comment
  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

5 minutes ago, Manouk said:

@media screen and (max-width:767px) {

#enter-block-id-here>div {

text-align: center !important;

}

}

You need to replace this text "#enter-block-id-here" with the actual block ID you want it to apply to.

How to find the block ID:
https://squarefortytwo.com/squarespace-guides/find-an-id-in-squarespace-71

Please like and upvote if my comments were helpful to you. Cheers!

Zygmunt Spray
Squarespace Website Designer
Contact me: 
https://squarefortytwo.com 

🔌 Ghost Squarespace Plugins (Referral link)
📈 SEO Space (Referral link)
 SquareWebsites Plugins (Referral link)
Spark Plugin (Referral link) 

 Did I help? Buy me a coffee?

Link to comment
  • 3 months later...

Hi there,
I'm using the blog-id, but I can't make this work. Do you have any other suggestions? Thanks a lot! 

 


@media screen and (max-width:767px) {

#block-2c06e5bedf7554ffcf3f>div {

text-align: center !important;

}

}

Website: www.possing.dk 

Link to comment

The code works just fine in my testing. Can you share the page you are trying to get this to work on?

Please like and upvote if my comments were helpful to you. Cheers!

Zygmunt Spray
Squarespace Website Designer
Contact me: 
https://squarefortytwo.com 

🔌 Ghost Squarespace Plugins (Referral link)
📈 SEO Space (Referral link)
 SquareWebsites Plugins (Referral link)
Spark Plugin (Referral link) 

 Did I help? Buy me a coffee?

Link to comment

Thanks for looking into it! 

It's on the front page of www.possing.dk - second section. 
 

@media screen and (max-width:767px) {

#block-2c06e5bedf7554ffcf3f>div {

text-align: center !important;

}

}

Skærmbillede 2023-06-07 kl. 11.41.43.png

Link to comment

I can't see any evidence of the CSS in your page code, but I also still don't see any reason why it wouldn't work if you've applied it in Custom CSS. It may not work if you have errors in the Custom CSS.

I'm not sure how to help further unless you can give me access to this website.

Please like and upvote if my comments were helpful to you. Cheers!

Zygmunt Spray
Squarespace Website Designer
Contact me: 
https://squarefortytwo.com 

🔌 Ghost Squarespace Plugins (Referral link)
📈 SEO Space (Referral link)
 SquareWebsites Plugins (Referral link)
Spark Plugin (Referral link) 

 Did I help? Buy me a coffee?

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.