javascript - Change css dynamically with window.resize() -
is there variant change block width window.resize(), if have set rules?
let's have block width , width jquery:
var $block_1_width = $(".block_1").width(); i need make block have same width, first one. so, write:
var $block_2 = $(".block_2"); $block_2.css("width", $block_1_width + "px"); if load page, work fine, want them dynamically keep same size @ window width when user resizes page. so, try:
$(window).resize(function() { $block_2.css("width", $block_1_width + "px"); }); and doesn't. know when wrote $block_2.css("width", $block_1_width + "px"), jquery set inline style $block_2. mean cannot override window.resize()?
you need re-calculate $block_1_width after resize so:
$(window).resize(function() { var $block_1_width = $(".block_1").width(); $block_2.css("width", $block_1_width + "px"); });
Comments
Post a Comment