I’m not sure if my question makes sense but I’m trying to make my linear gradient stay fixed on different screen sizes. The CSS property is this
background: linear-gradient(to right, #00008B 19.5%, #E60026 0%);
I have a logo in between the two color and I want the colors at the specified dimension. For example, if my logo is Stackoverflow– I want the blue hex-code at 19.5% to stay at ‘Stack’ while the remaining percentage occupies the ‘overflow’ on all screen sizes. I hope my problem is clear
I have tried background-attachment: fixed but its not working
2
Answers
Really small answer based off Temani Afif’s comment.
I don’t know if I understood your question correctly.
Is your question that the logo has different sizes on different screens and now you want the background of the logo to be a certain color and the empty space around the logo to be a different color?
If this is your question, you can use this solution.
Consider the size of your logo relativ to parent element or screen.
If the size is determined relative to the parent, use percent. it is a good choice, now you should also use percent for the gradient.
If it is determined by the ratio of the monitor, VW is a better choice. Now you have to use VW for the gradient as well.
If I understand your question correctly, I guarantee that this answer is correct. You just need to do some math.
for example if your logo is 200 * 200
html:
css: