CanaryNoir
3/17/2016 - 5:48 PM

positioning element relative to another element's size

positioning element relative to another element's size

$(document).ready(function(){
  try {
    var imgW = $('img.fright').width();
    var imgH = $('img.fright').height();
      console.log('h ' + imgH);
    var pos = $('img.fright').position();
    $('.imgCaption').css({
      'width':imgW+'px',
      'position':'absolute',
      'top': (imgH+5) + 'px',
      'left': pos.left,
      'text-align': 'center'
    });
  } catch(ex) {
    console.log(ex.toString());
  }
});