比如说两个块元素我想让他们等高,其中任何一个高度变了,它们的高度会变为其中最高的那个!我用offsetHeight做了,他只有刷新页面才会变
然后我用父级overflow:hidden
两个块分别margin-bottom:-10000px;padding-bottom:10000px;
但是问题来了:
效果可以实现但是两个块无法加上底边框!因为父级overflow:hidden了!里面的文字也不能垂直居中 line-height是失效的;有什么其他的方式可以处理????
//
<ul id="ul"> <li class="a" id="seller">a</li> <li class="b" id="cont">b</li></ul>
//
<下面是我刚开始用js做的,有问题,看看有什么地方要改进的,或者看看有什么其他方式>
function $(id){ return document.getElementById(id) ;} ;function getHeight(){ if($("seller").offsetHeight>=$("cont").offsetHeight){ $("cont").style.height=$("seller").offsetHeight + "px"; } else{ $("seller").style.height=$("cont").offsetHeight + "px"; } } getHeight()
慕码人2483693
相关分类