div内容完全加载后如何获取div高度

时间:2016-12-04 14:47:41

标签: jquery css

我的页面有两个div ..

左边div是一组链接,右边div是内容容器,它有段落和图像..

右边的div有一个自动高度。当窗口打开时,或者当我通过jquery调整窗口大小时,左侧div占用了正确的div高度。

问题是,左div在右div的内容加载完全加载之前占据了正确的div的高度。所以它需要错误的高度

这是问题的图像

enter image description here

这里是完整的代码



 $('.left').height($('.right').height());

a {
  display: block;
  padding: 20px;
}
.left {
  background: #EEE;
  position: absolute;
  left: 0;
  top: 0;
  width: 250px;
}
.right {
  width: 700px;
  margin-left: 250px;
  background-color: darkseagreen;
}
.right img {
  margin-top: 10px;
}

<script src="https://code.jquery.com/jquery-3.1.1.js" integrity="sha256-16cdPddA6VdVInumRGo6IbivbERE8p7CQR3HzTBuELA=" crossorigin="anonymous"></script>
<div class="left">
  <a href="#">Home</a>
  <a href="#">profile</a>
  <a href="#">about</a>
  <a href="#">ask</a>
  <a href="#">etc</a>
</div>
<div class="right">
  <h4>this is content</h4>
  <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It
    has survived not only five centuries, of Lorem Ipsum.</p>
  <img src="http://placehold.it/350x150">
  <img src="http://placehold.it/350x150">
  <img src="http://placehold.it/350x150">
</div>
&#13;
&#13;
&#13;

他的问题是......如何在加载

之后取得正确的div高度

0 个答案:

没有答案