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
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 

  Did I help? Buy me a coffee?

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

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 

  Did I help? Buy me a coffee?

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

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 

  Did I help? Buy me a coffee?

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

Link to comment
  • 6 months later...

I'm having a similar issue. I have separate text blocks: some with pricing and some with text only. The text only is centering but the pricing is not. Here is the code I'm using for the first two, as an example. 

@media screen and (max-width: 767px) {
#block-yui_3_17_2_1_1704401863200_30305 { 
  text-align: center;
}
#block-e84e5c5da83dc603066e {
    text-align: center;
}

}

https://blenny-indigo-cspb.squarespace.com/weddings

pw: 550Reach

Link to comment
On 1/5/2024 at 4:58 AM, grxdesigner38 said:

I'm having a similar issue. I have separate text blocks: some with pricing and some with text only. The text only is centering but the pricing is not. Here is the code I'm using for the first two, as an example. 

@media screen and (max-width: 767px) {
#block-yui_3_17_2_1_1704401863200_30305 { 
  text-align: center;
}
#block-e84e5c5da83dc603066e {
    text-align: center;
}

}

https://blenny-indigo-cspb.squarespace.com/weddings

pw: 550Reach

Use some code like this, this code for $6000 text

@media screen and (max-width:767px) {
div#block-69164261090989ef09db .sqs-html-content {
    display: flex;
    text-align: center !important;
    align-items: center;
    justify-content: center;
}
div#block-69164261090989ef09db .TextShape-node {
    left: 50% !important;
    transform: translateX(-50%) !important;
}
}

image.png.d38324105f583b155a6aa79d5692882e.png

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment
  • 1 month later...

Hi,
Thank for the tips above, I've tried to apply the same to my footer and it works but only on one of the text ID blocks, really weird that it works on one and not the other!

The code I am using is:

@media only screen and (max-width: 767px) {
#block-yui_3_17_2_1_1705006258059_14874, 
#block-c84e76b20faf907912e8, 
 { 
text-align: center !important; 
  }}

 

You can see in the screenshot, I'd like the Go-to and Contact text boxes to be aligned centrally on mobile only. On desktop I have one aligned to the left and one aligned to the right which I am happy with.

 

Website:

www.claretestar.com
Dodger50!

 

Thanks in advance

 

 

 

image.png.84b790a148db94c2a44afae6c19caf80.png

Link to comment

Try removing the unnecessary comma after the last block ID:

@media only screen and (max-width: 767px) {
  #block-yui_3_17_2_1_1705006258059_14874, #block-c84e76b20faf907912e8 { 
    text-align: center !important; 
  }
}

 

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

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

  Did I help? Buy me a coffee?

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

Link to comment
18 minutes ago, RebelRuth said:

Can you think of any other solutions?

Slight adjustment:

@media only screen and (max-width: 767px) {
  #block-yui_3_17_2_1_1705006258059_14874 .sqsrte-small, #block-c84e76b20faf907912e8 .sqsrte-small {
    text-align: center !important;
  }
}

 

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

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

  Did I help? Buy me a coffee?

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

Link to comment
11 minutes ago, RebelRuth said:

@Ziggy THANK YOU!! It works!! 😀

Happy to help, can you give my post a like?

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

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

  Did I help? Buy me a coffee?

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

Link to comment
  • 2 weeks later...

Hello,

I have tried the code in your comments but I can't make it work! Can you help me? 

I want to center the text block of the first two paragraphs (it's one block only). 

 

cryoheal.com.mx - Psw: javiykarla

image.thumb.png.4795c9b1ffd5f32e957328bf2fac6c05.png

 

Link to comment
On 3/24/2024 at 11:29 AM, JimenaD said:

Hello,

I have tried the code in your comments but I can't make it work! Can you help me? 

I want to center the text block of the first two paragraphs (it's one block only). 

 

cryoheal.com.mx - Psw: javiykarla

image.thumb.png.4795c9b1ffd5f32e957328bf2fac6c05.png

 

You can use a CSS code like this

@media screen and (max-width:767px) {
div#block-40c409a322dac564a740 * {
    text-align: center !important;
}
}

 

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

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.