The positions of my dot keeps moving depending on the mobile device how would I keep the button(dot) on my website to stay in the same position no matter the device. How could I fix this.
Website : https://sitharr.myshopify.com/
A user is experiencing issues with a clickable dot element that shifts position across different mobile devices and viewports. They need the dot to maintain a consistent position regardless of screen size.
Proposed Solution:
position: relative, centered margins, and transform propertiesCurrent Status:
calc() functions and transform: translate() for centeringTechnical Details:
The positions of my dot keeps moving depending on the mobile device how would I keep the button(dot) on my website to stay in the same position no matter the device. How could I fix this.
Website : https://sitharr.myshopify.com/
You should be aware that it is challenging to make a clickable point adapt dynamically to the width and height of the background image/video. However, you can try the following:
.dot {
width: 12px;
height: 12px;
background-color: #ffffff; /* White color */
border-radius: 50%; /* Make it a circle */
cursor: pointer;
border: none;
outline: none;
position: absolute; /* Position dot relative to the body */
top: calc(72.7%); /* Center vertically */
left: calc(54.9%); /* Center horizontally */
transform: translate(-50%, -50%); /* Center the dot */
}
.dot {
display: block;
width: 12px;
height: 12px;
position: relative;
margin: 53.5vh auto;
background-color: #ffffff;
border-radius: 50%;
cursor: pointer;
border: none;
outline: none;
transform: translate(8.8vh, 5vh);
}
Results:
By the way, you should also remove this code. It is responsible for manually adjusting the position of the point on the screen. It conflicts with the code I provided, so you must remove it if you want to see the previous results.
Thank you for your help but the dot keeps changing position depending on the viewport. Thanks a lot for your help though
Could you send the whole code in here so I could just try just in case I did something wrong
Thank you
The code I provided is what you should add to your code. However, from what I see, you’ve already managed to fix the error you had!