LoginSignup
0
1

More than 3 years have passed since last update.

Lazyloadの影響でmatchHeight.jsがうまく機能しない時

Last updated at Posted at 2021-03-12

やりたいこと

画像遅延の「Lazy Load」を使いつつ、
jQueryプラグイン「matchHeight.js」で横並びにした要素の高さを揃えたい。

問題点

「Lazy Load」の影響で、揃えたい要素(画像を内包)の高さが0と判定される。

解決策

画像の読み込みが完了してから、matchHeight.jsで高さを揃えるようにする。

$(window).on('load resize',function(){
  var target_img = $('.target img');
  target_img.on('load', function() {
    $('.target').matchHeight();
  });
});
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1