Re: Center an image

Center an image

Leeloo
Excursionist
45 0 11

I have a simple image of a heading on my home page placed using this code.

 

img {
display: block;
max-width: 40%;
}

 

It is currently justified to the left.  Can someone tell me the correct code to centre it. 

 

Thanks

Replies 8 (8)

GTLOfficial
Shopify Partner
624 135 123

Hello @Leeloo 
can you please provide the screen shot of your heading image.

- Buy me a Pizza
- If helpful then please Like and Accept Solution.
- Want to modify or custom changes or bug fix on the store Hire me. GTL web solutions
- Want Complete Storefront: Send an email ⇨- Email: info@gtlofficial.com - Skype: ritesh_27dh
Leeloo
Excursionist
45 0 11

Thanks so much!! That worked! I was having trouble attaching a screenshot!! 😝

Leeloo
Excursionist
45 0 11

Hey again.  That worked but it's become super tiny on the mobile view?  Anything I can do to fix it? Thank you!

Leeloo
Excursionist
45 0 11

The url is www.chantalhandley.com and it's the image that says 'Fine Art by Chantal Handley'. Looks great on the desktop view! 😄

 

Thank you!

Leeloo
Excursionist
45 0 11

Yep!!  👍 Thanks! Bought you a coffee! 😍

GTLOfficial
Shopify Partner
624 135 123

Hello @Leeloo 
Go to online store ----> themes ----> actions ----> edit code---->base.css
add this code at the end of the file.

@media screen and (max-width: 749px) {
#shopify-section-template--17303032529118__custom_liquid_qdtqTq img {
display: block;
max-width: 60%;
margin: 0 auto;
}
}

result
1.png

If this was helpful, hit the like button and accept the solution.
Thanks

- Buy me a Pizza
- If helpful then please Like and Accept Solution.
- Want to modify or custom changes or bug fix on the store Hire me. GTL web solutions
- Want Complete Storefront: Send an email ⇨- Email: info@gtlofficial.com - Skype: ritesh_27dh
Leeloo
Excursionist
45 0 11

Not sure it worked?

Sangeetanahar
Trailblazer
556 36 66

hello @Leeloo 

Can you tell me exactly which image heading you are talking about? Please take a screenshot and tell me.

thanks

Was I helpful?

Buy me a coffee



Want to modify or custom changes or bug fix on store . Or Need help with your store? Or -Want Complete Storefront
Email me -sangeetarahuldhiman@gmail.com - Skype: live:sangeetarahuldhiman -Whatsapp: +917009811712
Checkout Some Free Sections Here