有一个页面从左到右分为三块,中间一块div高度是随着数据的增加而边长,怎样使左右2边的div也边长?
最右边的窄边,高度是repeat的。
css如下:
.rightLine {
height: 955px;
background-image: url(/LogService/images/right.jpg);
background-repeat: repeat-y;
width: 26px;
position: absolute;
top: 54px;
left: 1225px;;
}
<div class="left"></div>
<div class="center"></div>
<div class="right"></div>
$(".left").height($(".showListDiv").height());
$(".right").height($(".showListDiv").height());
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<meta charset="utf-8">
<style type="text/css">
.green{
background-color:green;
}
.yellow{
background-color:yellow;
}
.red{
background-color:red;
}
table{
height:500px;
}
td{
width:200px;
}
</style>
</head>
<body>
<table>
<tr>
<td class="green"></td>
<td class="yellow" id="main"></td>
<td class="red"></td>
</tr>
</table>
<script type="text/javascript" >
window.onload = function(){
var obj = document.getElementById('main');
function getData(){
var str = obj.innerHTML, i, len, temp = "";
for(i=0,len=20;i<len;i++){
temp += i+"<br/>";
}
obj.innerHTML = str + temp;
}
setTimeout(function(){
getData();
setTimeout(arguments.callee, 2000);
},2000);
}
</script>
</body>
</html>
我有个办法可以不用js,利用table的td特性,当然你也可以不用table标签,用display:table和table-cell,效果一样的。demo代码如下:<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<meta charset="utf-8">
<style type="text/css">
.green{
background-color:green;
}
.yellow{
background-color:yellow;
}
.red{
background-color:red;
}
table{
height:500px;
}
td{
width:200px;
}
</style>
</head>
<body>
<table>
<tr>
<td class="green"></td>
<td class="yellow" id="main"></td>
<td class="red"></td>
</tr>
</table>
<script type="text/javascript" >
window.onload = function(){
var obj = document.getElementById('main');
function getData(){
var str = obj.innerHTML, i, len, temp = "";
for(i=0,len=20;i<len;i++){
temp += i+"<br/>";
}
obj.innerHTML = str + temp;
}
setTimeout(function(){
getData();
setTimeout(arguments.callee, 2000);
},2000);
}
</script>
</body>
</html>