Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Responsive background images – fit one dimension, expand other dimension Reply To: Responsive background images – fit one dimension, expand other dimension

#150234
victorhooi
Participant

Hi,

@georgearnall – Cool, thanks for that =).

I was hoping there was a pure CSS solution, but that code is pretty concise.

So if I just attach this to the onReady for the page, it’ll happen once when the page renders, right? If I want it to work when they also resize the window, should I also attach it to the window.onresize event?

Also, one thing I noticed was that as you scroll, the “photo1” and “photo2” text seem to remain stationary on the page, while everything else scrolls.

This is on Chrome on OSX.

Is that normal behaviour?

When I was using actual photographs, I noticed weird scrolling as well – the content would scroll up/down, but the background image seemed to remain where it was, if that makes any sense.

Is there any way to make it all scroll together?

Cheers,
Victor