简体   繁体   English

如何确保两个div在jQuery Mobile中始终具有相同的高度

[英]How to ensure that two div always have same height in jQuery Mobile

I am very new to jquery mobile framework, so kindly bear with me.I am developing a project where i need to show that data in tabular format. 我对jQuery移动框架非常陌生,请耐心等待。我正在开发一个项目,需要以表格格式显示该数据。 So i have used below structure to create left and right column. 所以我用下面的结构来创建左右列。

<div data-role="controlgroup" data-theme="d" class="ui-grid-m ui-corner-all ui-controlgroup ui-controlgroup-vertical">  
        <div id="left" class="ui-block-m">
            <li>Moisture Sensitivity Level (MSL)</li>
        </div>
        <div id="right" class="ui-block-n">
            <li>  3      </li>
        </div>
</div>

But problem is when i have a large string in any of the one column and shorter string in other column, then height of column get's distorted. 但是问题是当我在任一列中有一个大字符串而另一列中有一个较短的字符串时,那么列的高度就会失真。 So, my question is how can i ensure that both the div(Which i am using as columns having classes ui-block-m and ui-block-n) have same hieght. 所以,我的问题是我如何才能确保div(我用作具有ui-block-m和ui-block-n类的列)具有相同的高度。

Any suggestion is highly appreciated. 任何建议都将受到高度赞赏。 Thanks in advance!!. 提前致谢!!。

How can i ensure that div with class ui-block-m and div with class ui-block-n 我如何确保ui-block-m类的div和ui-block-n类的div

quick and dirty: 快速又肮脏:

$(function(){
    var $m = $('.ui-block-m');
    var $n = $('.ui-block-n')
    if($m.height() < $n.height()){
        $m.css('height',$n.height());
    }else if($m.height() > $n.height()){
        $n.css('height',$m.height());
    }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM