Skip to content Skip to sidebar Skip to footer

Jquery .height() Wrong In Safari

I have a problem reading out the correct height of a DIV with jQuery in Safari. I am using jQuery('#x').height() to read out the height of the element. In the real situation, I use

Solution 1:

I changed your css so that safari doesn't change height of image.

#x {
  position: absolute;
  top: 0px;
  margin-top: 80px;
  right: 54%;
  width: auto;
  height: auto;
  /* max-width: 330px; */padding: 10px43px16px;
  background: #ddd;
}
.y {
  position: relative;
  width: 100%;
  max-width: 330px;
  height: auto;
  max-height: 330px;
}
.yimg {
  width: auto;
  height: auto;
}

Also use load function to fetch exact height of #x.

$(window).load(function(){
   console.log($("#x").height());  
});

You can refer the changed code here.

Post a Comment for "Jquery .height() Wrong In Safari"