自举3.0 - 垂直对齐3面板同一行中(自动高度) [英] Bootstrap 3.0 - Vertically align 3 panels in the same row (Auto Height)

查看:267
本文介绍了自举3.0 - 垂直对齐3面板同一行中(自动高度)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

试图为3的面板的单一行,其中的高度膨胀根据内容,它们都正确对齐。左侧面板将具有在它的曲线图,这两个在​​右侧将具有与在左侧的曲线图的工作表。
这个工作的
例子是这样的模板:点击这里有个例子

 < D​​IV CLASS =行>
    < D​​IV CLASS =COL-MD-8>
        < D​​IV CLASS =面板面板默认>
            < D​​IV CLASS =面板标题>
                < H3类=面板标题>面板标题< / H3>
            < / DIV>
            < D​​IV CLASS =面板体>面板内容
            < / DIV>
        < / DIV>
    < / DIV>
    < D​​IV CLASS =COL-MD-4>
        < D​​IV CLASS =面板面板默认>
            < D​​IV CLASS =面板标题>
                < H3类=面板标题>面板标题< / H3>
            < / DIV>
            < D​​IV CLASS =面板体>面板内容
            < / DIV>
        < / DIV>
        < D​​IV CLASS =面板面板默认>
            < D​​IV CLASS =面板标题>
                < H3类=面板标题>面板标题< / H3>
            < / DIV>
            < D​​IV CLASS =面板体>面板内容
            < / DIV>
        < / DIV>
    < / DIV>
< / DIV>
 

解决方案

巢网格列,请参阅: HTTP:// getbootstrap .COM / CSS /#格嵌套

例: http://bootply.com/79487

HTML

 < D​​IV CLASS =容器>
    < D​​IV CLASS =行>

        < D​​IV CLASS =COL-SM-6>
                         < D​​IV CLASS =面板面板成功>
                            < D​​IV CLASS =面板标题>
                              < H3类=面板标题>曲线< / H3>
                            < / DIV>
                            < D​​IV CLASS =面板体>
                              < IMG SRC =htt​​p://dummyimage.com/600x500/000/fff&text=Graph级=IMG响应>
                            < / DIV>
                          < / DIV>
            < / DIV>



        < D​​IV CLASS =COL-SM-6>
                < D​​IV CLASS =行>
                    < D​​IV CLASS =COL-SM-12>
                          < D​​IV CLASS =面板面板主>
                            < D​​IV CLASS =面板标题>
                              < H3类=面板标题>面板标题< / H3>
                            < / DIV>
                            < D​​IV CLASS =面板体>
                              面板内容
                            < / DIV>
                          < / DIV>
                        < / DIV>
                    < D​​IV CLASS =COL-SM-12>
                          < D​​IV CLASS =面板面板成功>
                            < D​​IV CLASS =面板标题>
                              < H3类=面板标题>面板标题< / H3>
                            < / DIV>
                            < D​​IV CLASS =面板体>
                              面板内容
                            < / DIV>
                          < / DIV>
                    < / DIV>
                < / DIV>
        < / DIV>
    < / DIV>
< / DIV>
 

更新我忘了autoheight一部分上面的例子中,你可以使用从<一个href="http://stackoverflow.com/a/12330800/1596547">http://stackoverflow.com/a/12330800/1596547:

  $(窗口).load(函数(){

箱= $('COL-SM-6。');
=了maxHeight Math.max.apply(
数学,boxes.map(函数(){
返回$(这).height();
})。得到());
boxes.height(了maxHeight);
$('COL-SM-12 .panel。')的高度(了maxHeight / 2-22); // 22 = 20(底缘)+ 2 * 1(边界)
});
 

Trying to have a single row of 3 panels where the height expands according to the content and they all align properly. The left panel would have a graph in it, the two on the right would have tables that work with the graph on the left.

Example of this working is this template: Click Here For Example

<div class="row">
    <div class="col-md-8">
        <div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title">Panel title</h3>
            </div>
            <div class="panel-body">Panel content
            </div>
        </div>
    </div>
    <div class="col-md-4">
        <div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title">Panel title</h3>
            </div>
            <div class="panel-body">Panel content
            </div>
        </div>
        <div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title">Panel title</h3>
            </div>
            <div class="panel-body">Panel content
            </div>
        </div>
    </div>
</div>

解决方案

Nest your grid columns, see: http://getbootstrap.com/css/#grid-nesting

Example: http://bootply.com/79487

html

<div class="container">
    <div class="row">

        <div class="col-sm-6">
                         <div class="panel panel-success">
                            <div class="panel-heading">
                              <h3 class="panel-title">Graph</h3>
                            </div>
                            <div class="panel-body">
                              <img src="http://dummyimage.com/600x500/000/fff&amp;text=Graph" class="img-responsive">
                            </div>
                          </div>
            </div>



        <div class="col-sm-6">
                <div class="row">
                    <div class="col-sm-12">
                          <div class="panel panel-primary">
                            <div class="panel-heading">
                              <h3 class="panel-title">Panel title</h3>
                            </div>
                            <div class="panel-body">
                              Panel content
                            </div>
                          </div>
                        </div>  
                    <div class="col-sm-12">  
                          <div class="panel panel-success">
                            <div class="panel-heading">
                              <h3 class="panel-title">Panel title</h3>
                            </div>
                            <div class="panel-body">
                              Panel content
                            </div>
                          </div>    
                    </div>
                </div>  
        </div>          
    </div>      
</div>

update i forgot the autoheight part for the example above you could use from http://stackoverflow.com/a/12330800/1596547:

$( window ).load(function() {   

boxes = $('.col-sm-6');
maxHeight = Math.max.apply(
Math, boxes.map(function() {
return $(this).height();
}).get());
boxes.height(maxHeight);
$('.col-sm-12 .panel').height(maxHeight/2-22);//22 = 20 (bottom-margin) + 2 *1 (border)
});

这篇关于自举3.0 - 垂直对齐3面板同一行中(自动高度)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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