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

#150317
georgearnall
Participant

If you are already have a JS file that will run, you can just include that snippet somewhere and it will work. To make it update when people resize and on document ready, use this:

$(function() {
    $('section').css('height', innerHeight);
  $(window).resize(function() {
    $('section').css('height', innerHeight);
  });
});

See this in CodePen :)