如何设置一个'div'高度与他的邻居相同? [英] How to set a 'div' height same with his neighbor?

查看:245
本文介绍了如何设置一个'div'高度与他的邻居相同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用bootstrap作为我的CSS框架。现在我在左侧div中有一些动态内容,右侧div有一些静态内容。我想要的右边div的高度自动改变基础的左边div的高度。可能吗?

 < div class =container-fluid> 
< div class =row-fluid>
< div class =span5 offset1>
< div class =well>
动态内容
< / div>
< / div>
< div class =span5>
< div class =wellstyle =height:330px; overflow-x:hidden; overflow-y:scroll;>
静态内容
< / div>
< / div>
< / div>

解决方案>

我认为jQuery是实现这一点的最佳解决方案。查看我的小提琴:



http://jsfiddle.net/ PHjtJ /

  $(document).ready(function(){

var dynamic = $('。dynamic');
var static = $('。static');

static.height(dynamic.height());

});


I am using bootstrap as my CSS framework. Now I have some dynamic content in the left side div, and some static content in the right div. I want to the height of right side div auto change base on the height of left side div. Is that possible?

<div class="container-fluid">
  <div class="row-fluid">
    <div class="span5 offset1">
    <div class="well">
      Dynamic Content
    </div>
  </div>
  <div class="span5">
    <div class="well" style="height: 330px; overflow-x: hidden; overflow-y: scroll;">
      Static Content
    </div>
  </div>
</div>

解决方案

I think jQuery is the best solution to achieve this. Check out my fiddle:

http://jsfiddle.net/PHjtJ/

$(document).ready(function() {

    var dynamic = $('.dynamic');
    var static = $('.static');

    static.height(dynamic.height());

});

这篇关于如何设置一个'div'高度与他的邻居相同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆