New Shopify Certification now available: Liquid Storefronts for Theme Developers

Centering a Lottie Animation.

Solved
ThijsV88
Tourist
11 0 0

Hello, I'm working on my store and want to add a Lottie Animation. When added it's not centered, sadly I don't know much about code. I've only added this in a plain custom liquid section, obviously it won't center, but the problem is that I don't know/cou a fix 😔. Hopefully someone can help me out with centering it (from as far as I know it does already properly center on mobile): 

 

<script src="https://unpkg.com/@lottiefiles/lottie-player@latest/dist/lottie-player.js"></script>
<lottie-player src="https://assets1.lottiefiles.com/packages/lf20_uhsngkt4.json" background="transparent" speed="1" style="width: 300px; height: 300px;" loop autoplay></lottie-player >

 

Kinds regards,

T.

Accepted Solution (1)
ExpertRookie
Shopify Partner
1518 249 303

This is an accepted solution.

@ThijsV88 

 

You can add this code to Edit code > assets > base.css file at the end

lottie-player {
display: block;
margin : 0 auto;
}
- Was my reply helpful? Please Like and Accept Solution to let me know!
- Want to modify or custom changes on store Hire me.
- Feel free to contact me on expert.rookie.team@gmail.com regarding any help.

View solution in original post

Replies 11 (11)
ExpertRookie
Shopify Partner
1518 249 303

@ThijsV88 

Try to ad this code to a css file

lottie-player {
display: block;
margin : 0 auto;
}

Try it and let me know

- Was my reply helpful? Please Like and Accept Solution to let me know!
- Want to modify or custom changes on store Hire me.
- Feel free to contact me on expert.rookie.team@gmail.com regarding any help.
ThijsV88
Tourist
11 0 0

Hey thanks for the quick response! I won't lie, I'm not too sure if I'm doing it right, but I think it doesn't work. I've currently added your code to the bottom and top of a css file with the Lottie Animation. When doing that it will simply show up as plain text. Could definitely be the case that I'm doing something silly though... 

ExpertRookie
Shopify Partner
1518 249 303

@ThijsV88 

 

Could you share your store URL? then I can review it

- Was my reply helpful? Please Like and Accept Solution to let me know!
- Want to modify or custom changes on store Hire me.
- Feel free to contact me on expert.rookie.team@gmail.com regarding any help.
ThijsV88
Tourist
11 0 0
ExpertRookie
Shopify Partner
1518 249 303

@ThijsV88 

 

Try this code

 

<style>
lottie-player {
display: block;
margin : 0 auto;
}</style>

 

- Was my reply helpful? Please Like and Accept Solution to let me know!
- Want to modify or custom changes on store Hire me.
- Feel free to contact me on expert.rookie.team@gmail.com regarding any help.
ThijsV88
Tourist
11 0 0

Sadly this still doesn't seem to work for me

ExpertRookie
Shopify Partner
1518 249 303

@ThijsV88 

 

I checked and it seems you does not use the new code yet.

 

- Was my reply helpful? Please Like and Accept Solution to let me know!
- Want to modify or custom changes on store Hire me.
- Feel free to contact me on expert.rookie.team@gmail.com regarding any help.
ExpertRookie
Shopify Partner
1518 249 303

This is an accepted solution.

@ThijsV88 

 

You can add this code to Edit code > assets > base.css file at the end

lottie-player {
display: block;
margin : 0 auto;
}
- Was my reply helpful? Please Like and Accept Solution to let me know!
- Want to modify or custom changes on store Hire me.
- Feel free to contact me on expert.rookie.team@gmail.com regarding any help.
ThijsV88
Tourist
11 0 0

This seems to do the job, thanks a bunch!

ExpertRookie
Shopify Partner
1518 249 303

@ThijsV88 you are welcome

- Was my reply helpful? Please Like and Accept Solution to let me know!
- Want to modify or custom changes on store Hire me.
- Feel free to contact me on expert.rookie.team@gmail.com regarding any help.
HELDERWRLD
Excursionist
77 0 4

Hello mate,
I'm looking to do something similar. Does this way still work in 2023? I use the dawn theme and my site is: https://c04baf-2.myshopify.com/ (Diversusoficial is the code)

I want to do something like this: https://gemoo.com/tools/upload-video/share/567241571823239168?codeId=P5pqQ30lKl97K&card=567241566878...