CSS/PHP:如何使左侧和右侧float div具有相同的高度,而不管其中包含多少信息?
如何使左侧和右侧浮动div具有相同的高度,而不管其中包含多少信息?div的数量是动态创建的,左右交替,以及其中的信息CSS/PHP:如何使左侧和右侧float div具有相同的高度,而不管其中包含多少信息?,php,css,Php,Css,如何使左侧和右侧浮动div具有相同的高度,而不管其中包含多少信息?div的数量是动态创建的,左右交替,以及其中的信息 <div class="columns"> <?php $cemp = true; foreach ( $req_user_emp as $id => $name ) { echo "<div ".(($cemp = !$cemp)?" class=\"column_right\"":" class=\"column_lef
<div class="columns">
<?php
$cemp = true;
foreach ( $req_user_emp as $id => $name ) {
echo "<div ".(($cemp = !$cemp)?" class=\"column_right\"":" class=\"column_left\"").">";
echo "<h3>".$req_user_emp[$id]['position']."</h3>";
echo "<h4>".$req_user_emp[$id]['company_name']."</h4>";
echo $req_user_emp[$id]['description'];
echo "<div class=\"column_footer\">".$req_user_emp[$id]['start_date']." → ".$req_user_emp[$id]['end_date']."</div></div>";
}
?>
</div>
现在我在MySQL中有一些数据,我想将它们排列到这两列中。代码可以工作,但如果列中的数据不相等,则列排列不正确。
你知道怎么解决这个问题吗?
我还想在foreach函数中使用if:
if ( $i % 2 == 0 ) {
ENTER_MY_CODE_HERE;
}
像这样使用.row_级别的容器来表示.left和.right,但据我所知,这在IE中不起作用(我现在没有办法测试它)
谢谢没有简单的方法可以使所有浮动元素达到100%的高度。最好的方法是
高度:100%
或顶部:0;底部:x代码>如果已知高度。否则,您将使用视觉技巧。您可以使用两种解决方案:
第一个JS解决方案:
//equal heights
//usage : matchCols.init('.yourclass');
var compareVal;
var matchCols = {
init: function(matchClass){
// reset the start compare value
var compareVal = 0;
// get the heightest value
$(matchClass).each(function(){
if($(this).height()>compareVal){compareVal=$(this).height();}
});
/* set the heightest value */
$(matchClass).each(function(){
$(this).height(compareVal);
});
}
};
或CSS人造列视觉修复:
像这样的东西就可以了:。谢谢……我喜欢。很抱歉回复太晚。使用CSSmax height
属性怎么样?
//equal heights
//usage : matchCols.init('.yourclass');
var compareVal;
var matchCols = {
init: function(matchClass){
// reset the start compare value
var compareVal = 0;
// get the heightest value
$(matchClass).each(function(){
if($(this).height()>compareVal){compareVal=$(this).height();}
});
/* set the heightest value */
$(matchClass).each(function(){
$(this).height(compareVal);
});
}
};