代码如下,对比两个DIV的高度哪个高度高就调整另一个DIV的高度对其一致。这个DIV的作用比如我现在用的模板边栏和右边内容 中间是一条边界线,边界线我只用了一边,另一边如果高度不一致将会导致边界线有部分不显示。这时候下边代码就派上用场了。
<script type="text/javascript">function $(id){return document.getElementById(id) }function getHeight() {if ($("blog-offcanvas").offsetHeight>=$("blog-right").offsetHeight){ $("blog-right").style.height=$("blog-offcanvas").offsetHeight + "px"; }else{ $("blog-offcanvas").style.height=$("blog-right").offsetHeight + "px"; } } window.onload = function() {getHeight(); } </script>
上一篇:页面所有元素加载完成之后执行某个js函数
下一篇:没有了