I added a script to my website which is an announcement bar with icons. I liked the announcement bar and want to keep it. It looks normal on desktop, however on mobile version the announcement bar is causing the homepage to become wider and the sides are being cut off. Below I will leave a screenshot of how it looks without the announcement bar and a screenshot with the announcement bar for you to see how the screen becomes wider. Could someone make an edit to the script so that the bar doesn’t affect the screen size on mobile?
To fix the issue with the announcement bar causing the homepage to become wider on mobile devices, you can add the following code to the <style> section:
This code applies some additional styling to the announcement bar when the screen width is less than 768 pixels (i.e., on mobile devices). Specifically, it sets the flex-wrap property to wrap and the justify-content property to center on the .barra-de-anuncio__inner element to make the announcement bar items stack vertically and center them on the screen. It also sets the width of .barra-de-anuncio__content to 100% and sets the text-align property to center to center the content of each announcement bar item.
Here is the updated code with the new styles added:
Frete Grátis para todo o Brasil
Trocas e Devoluções em até 7 dias
Satisfação Garantida ou Dinheiro de Volta
I’ve added an overflow: hidden property to the .barra-de-anuncio class in the media query, which will prevent the bar from causing the page to become wider on mobile.