gpt4 book ai didi

css - Bootstrap 3.0 - 垂直对齐同一行中的 3 个面板(自动高度)

转载 作者:技术小花猫 更新时间:2023-10-29 10:29:22 26 4
gpt4 key购买 nike

尝试使用单行 3 个面板,其中高度根据内容扩展并且它们都正确对齐。左边的面板中会有一个图表,右边的两个面板会有与左边的图表配合使用的表格。

这个工作的例子是这个模板: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>

最佳答案

嵌套您的网格列,请参阅:http://getbootstrap.com/css/#grid-nesting

示例: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>

更新 我忘记了上面示例的自动高度部分,您可以使用 https://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)
});

关于css - Bootstrap 3.0 - 垂直对齐同一行中的 3 个面板(自动高度),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18664591/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com