Update on load and resize

Marko Krstić
18 Apr 2020
jQuery(document).ready(function($) {
  var adjust_size = function() {
  	// Change code here
    $('.content .right').width($(window).width() - 480);
	// Change code here
  };
  adjust_size();
  $(window).resize(adjust_size);
});	

This code will help you to get values on page load and change them on resize. It can be useful to update the CSS values and objects position.

Code example with breakpoint

jQuery(document).ready(function($) {
// Footer fixed
var adjust_size = function() {
var newWindowWidth = $(window).width();
	if (newWindowWidth > 991) {    
	    var footer = $(".footer").height();
		$(".main").css("margin-bottom", footer)
	}
	else
	{
		$(".main").css("margin-bottom", "0px")
	}
};
adjust_size();
$(window).resize(adjust_size);
// Footer fixed
});

Was this article helpful?

Tags

Categories

Never miss new post again

Subscribe and get list of new posts in your inbox

Click to Copy