Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
I am trying to make my announcement bar sticky. However if I apply the following code:
div#shopify-section-sections--21580379259203__announcement-bar {
position: sticky !important;
top: 0;
}
It covers half of the header as well.
Anyone knows what I can do in this instance?
Which theme are you using?
please add a margin top with the same height of the top bar like if your top bar is 50px then you need to give top-margin of the logo section like, margin-top:50px;
it will be very easy for me to share an exact code for you if you could provide me store url.
Thanks
please add below code into your css file where you already place the code.
Online Theme > Edit Code > Assets > base.css file.
.shopify-section-header-sticky.scrolled-past-header {
top: 40px !important;
}
That worked thanks! The only thing is that it is not working for mobile. Is there a way to fix this for mobile as well?
Ok let me share it
It is because your top bar is not sticky on mobile
Okay! How can I change this?
use below code for mobile
@media screen and (max-width: 767px) {
.shopify-section-header-sticky.scrolled-past-header {
top: 78px !important;
}
}
Thanks
Hello!
Thanks again for your incredible help. I added this code, however, it works on my shopify theme, but not on my regular mobile phone. Is there something else I can try?
Did you added this code i provided in the theme because i am not able to see that.
Yes I did!
replace the above code which i sent second time with this.
@media screen and (max-width: 767px) {
#shopify-section-sections--21580379259203__announcement-bar {
position: sticky !important;
top: 0 !important;
}
.section-header.shopify-section-group-header-group {
top: 78px !important;
}
}
It still does not work unfortunately
It is strange for me
Hey, @JesperW
I'm not formally trained in code to provide you with an exact solution to code a sticky announcement. However, I'm confident one of our Shopify experts would be able to accomplish this at a reasonable price.
Just wanted to share this as an option in case you are unable to find a coding solution in your thread.
Dirk | Social Care @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog
Hi, below what previous code should I insert your code to make the announcement bar sticky please?
I'm using 'Sense' theme.
Thanks
please use this code into your theme.liquid file paste it very before </body> thag
<style>
#shopify-section-announcement-bar {
position: fixed;
top: 0;
left: 0;
width: 100%;
}
</style>
It doesn't seem to be working for me, below is how I have inserted it...
please share your store URL?
please replace this code with previouse
<style>
.utility-bar {
position: fixed;
top: 0;
left: 0;
width: 100%;
z-index: 99999;
height: auto;
}
.header-wrapper {
margin-top: 40px;
}
</style>
It's almost perfect... on mobile it looks great, however on desktop there is a small gap between announcement bar & header that shows the scrolling page. Do you know how to fix this? Thanks
just reduce 1px from the 40px height.
Amazing. Thank you!! And whilst we're in conversation... Do you also know how to add payment provider icons to my announcement bar please?
yes this can be done with custom code.
please mark this thread as solved so that we will continue.
Sorry but I am struggling to find how I mark as solved?
@Lydia224 click on the three dots in this thread right side of this thread hopefully you will get that.
This is all I see...
@Lydia224 ok no problem leave it.
Are you able to help me with the payment icons on announcement bar please. I have started on a new discussion.. https://community.shopify.com/c/shopify-discussions/add-payment-icons-to-announcement-bar/m-p/295511...
Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025Discover opportunities to improve SEO with new guidance available from Shopify’s growth...
By Jacqui May 1, 2025