关于div自适应高度/左右高度自适应一致的js代码

时间:2013-03-22    点击:86   
在使用DIV和CSS进行网页布局中,DIV的自适应高度和自适应宽度是一个很常见的问题。
为了保证页面的整体美观性,需要将两个或者多个层的高度/宽度保持一致。

左右自适应高度一致 Jquery
复制代码 代码如下:

<div style="width:300px;">
<div id="Left" style="float:left;background-color:blue;">1<br/>3<br/>5<br/></div>
<div id="Right" style="float:right;background-color:red;">2</div>
</div>
<script type="text/javascript" src="http://jt.875.cn/js/jquery.js"></script>
<script type="text/javascript">
$(function(){
var heightLeft= $("#Left").height();
var heightRight= $("#Right").height();
if (heightLeft > heightRight)
{
$("#Right").height(heightLeft);
}
else
{
$("#Left").height(heightRight);
}
})
</script>

DIV高度自适应屏幕 js
复制代码 代码如下:

<div id="top" style="height="200px;"></div>
<div id="box">dsafsafsafsafsafdsa</div>
<script>
window.onload=function (){
function auto_height()
{
//var h= document.documentElement.clientHeight-200;
//var high = document.getElementById("box");
//high.style.height=h+"px";
document.getElementById("box").style.height=document.documentElement.clientHeight-200+"px";
}
auto_height();
onresize=auto_height;
}
</script>
js实现上传图片之上传前预览图片
多个表单中如何获得这个文件上传的网址实现js代码
jquery中使用$(#form).submit()重写提交表单无效原因分析及解决
博客侧边栏模块跟随滚动条滑动固定效果的实现方法(js+jquery等)
js 字符串转换成数字的三种方法
> 返回     
地址:上海市普陀区胶州路941号长久商务中心 电话: QQ:
© Copyright 2012 上海网络 Product All Rights Reserved