日期:2014-05-17  浏览次数:20590 次

DIV+CSS 两列部局怎么使两例的高度一致?
DIV+CSS   两列部局怎么使两例的高度一致?
<div   id= "wrapper ">
<div   id= "sideslipe ">
</div>
<div   id= "content ">
</div>
</div>
写完CSS后,   发现sideslipe和content的高度不一样,   由于设置了背景,有点不好看了,   怎么使这两例高度一样呢?

------解决方案--------------------
要由于内容是不确定的,要使两列的高度一致,得用JS来控制
------解决方案--------------------
考虑用一个背景放到主DIV中来解决
------解决方案--------------------
try:
=================


<style type= "text/css ">
#wrapper {float:left;}
#sideslipe {width:50px;border:1px solid #630;float:left;}
#content {width:100px;border:1px solid #630;float:left;}
</style>

<body onload= "test(); ">
<div id= "wrapper ">
<div id= "sideslipe "> 测试测试测试测试测试测试 </div>
<div id= "content "> ddddddddddddd </div>
</div>
</body>

<script type= "text/javascript ">
function test(){
var a = document.getElementById( 'sideslipe ');
var b = document.getElementById( 'content ');
if (a.clientHeight > b.clientHeight){
b.style.height=a.clientHeight;
}
else {
a.style.height=b.clientHeight;
}
}
</script>
------解决方案--------------------
在wrapper层中使用背景

比如说最终效果是下边那样的,那就截一块做为wraper层的背景,Y方向重复

| ***************************************** | | *********************** |
| ***************************************** | | *********************** |
| ***************************************** | | *********************** |
| ***************************************** | | *********************** |