Having a dilemma here. I have this square image (2048x2048) that I want to set as a background. The tricky part is, I want it to display borders when the page stretches into widescreen mode, but also resize while maintaining its square shape when the page width is decreased.
It seems like I can't achieve both at the same time.
If I apply height:100%
as a CSS property for the image, it works well on larger screens. However, when the screen size shrinks, the image fails to adapt and creates unwanted horizontal scroll bars.
On the other hand, if I use width:100%
as a CSS property, it functions perfectly on small screens. But once the window expands to full size, vertical scroll bars become an issue.
I tried applying:
width:100%;
height:100%;
or
max-width:100%;
max-height:100%;
believing it would solve the problem, but unfortunately, it didn't work out.
I even attempted giving the body
tag max-height:100%
, and experimented with setting the same property for a container div, yet no success.
Would greatly appreciate any guidance or suggestions on how to tackle this challenge effectively. Thank you!