We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

Banner Button Position Question - Keep Aligned on Resize

Banner Button Position Question - Keep Aligned on Resize

mags_marie
Visitor
2 0 2

Hi, 

I am using the Dawn theme on my website (link). I added a "Shop Collections" button to the banner image and figured out how to reposition the button. But the problem is that the button doesn't adjust when the screen or browser size is changed. I need the button to automatically adjust so that it stays in the same place below the text. Nothing I have tried has worked. I'm hoping someone can offer a solution for this. Thanks so much! 

M
Screenshot 2024-05-08 at 6.41.06 AM.png
Screenshot 2024-05-08 at 6.41.23 AM.png

Replies 2 (2)

patrick521
Visitor
1 0 0

@mags_marieaarpmahjongg wrote:

Hi, 

I am using the Dawn theme on my website (link). I added a "Shop Collections" button to the banner image and figured out how to reposition the button. But the problem is that the button doesn't adjust when the screen or browser size is changed. I need the button to automatically adjust so that it stays in the same place below the text. Nothing I have tried has worked. I'm hoping someone can offer a solution for this. Thanks so much! 

M
Screenshot 2024-05-08 at 6.41.06 AM.png
Screenshot 2024-05-08 at 6.41.23 AM.png


Hello, @mags_marie 

 

To ensure that the “Shop Collections” button on your Dawn theme banner image remains in the correct position relative to the text across different screen sizes, you’ll need to use responsive CSS positioning. This typically involves using media queries to adjust the position of the button based on the screen size.

Here’s a general example of how you might use CSS to keep the button below the text and adjust its position responsively:

 

/* Default position for mobile and small screens */
.banner__button {
position: absolute;
bottom: 20px; /* Adjust as needed */
left: 50%;
transform: translateX(-50%);
}

/* Adjust position for larger screens */
@media (min-width: 750px) {
.banner__button {
bottom: 40px; /* Adjust as needed */
left: calc(50% + 100px); /* Adjust based on your layout */
}
}

 

You can add this CSS to your theme’s stylesheet or within a <style> tag in the theme.liquid file. Make sure to replace .banner__button with the actual class or ID of your button, and adjust the bottom and left values to fit your specific design.

 

I hope it's helpful for you.

 

Best Regard,
patrick521

Made4uo-Ribe
Shopify Partner
10211 2427 3079

Hi @mags_marie 

Because you use the position:absolute. So the position wont be steady on lower screen. 

Check this one I used the default from the theme. 

From your Shopify admin dashboard, click on "Online Store" and then "Themes".

Find the theme that you want to edit and click on "Actions" and then "Edit code".

In the "Assets" folder, click on "base.css, style.css or theme.css" file, depending on which file your theme uses to store its CSS styles. At the bottom of the file, add the following CSS code:

 

.banner--desktop-transparent .banner__box {
        position: unset;
        top: 0;
        right: 0;
    }
.banner__content.banner__content--top-left {
        align-items: flex-end !important;
}
.banner__box.content-container {
        padding-bottom: 0px;
}
.banner__content.banner__content--top-left.page-width {
        max-width: 100%;
}
@media only screen and (max-width: 1550px){
.banner__content.banner__content--top-left {
        padding-bottom: 20px;
        padding-left: 30px;
}
        }

 

And Save. 

Note; I take out this code. 

Made4uoRibe_0-1715170786063.png

If it wont listen would you mind to remove this code. Thanks!

Result:

Made4uoRibe_1-1715170860555.png

1800px screen View.

Made4uoRibe_2-1715170936670.png

1080px screen view. 

It will always stay there. I just adjust the paddings so it wont cover the text. 

 

 

 

Please don't forget to Like and Mark Solution to the post that helped you. Thanks!

If this fixed your issue, Likes and Accept as Solution are highly appreciated. Coffee tips fuel my dedication.
Get experienced Shopify developers at affordable rates—visit Made4Uo.com for a quick quote!
Need THEME UPDATES but have custom codes? No worries, for an affordable price.