首页
关于
生活
相册
QQ围脖
Code
订阅
两列(或者说N列)等高的写法
» 2009-9-17 13:24:20 已被归档于 Html/Css
前段时间,有朋友问我怎么做.我没想出来.刚开始用内补丁+外补丁的方法,可是.border却被overflow了..今天说的有两种方面:第一种是JS.第二种是图片背景:
第一种:JS方法
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <style type="text/css"> * { padding:0; margin:0; list-style:none; } html { height:100%; } body { font-family:Verdana, Geneva, sans-serif; font-size:14px; color:#555; height:100%; line-height:26px; } #wrap { width:960px; margin:0 auto; padding-top:50px; overflow:hidden; padding-bottom:20px; } #main { float:right; width:630px; border:1px solid #d5d5d5; padding:10px; } #sideBar { width:180px; margin-left:10px; display:inline; padding:10px; float:left; display:inline; border:1px solid #d5d5d5; background-color:#f7f7f7; } #sideBar0 { width:70px; float:left; border:1px solid #d5d5d5; padding:20px 10px 10px 10px; } </style> </head> <body> <div id="wrap"> <div id="sideBar0"></div> <div id="sideBar"></div> <div id="main"></div> </div> <script type="text/javascript"> var Class={ x:function(r,m){ for(var i=0;i<r;i++) {var c=document.createElement("div"); c.innerHTML=i; document.getElementById(m).appendChild(c); } }, y:function(){ var m=0,n=0,ar=0; if(arguments.length<2){alert("你没弟弟!");return false;} else{ for(var j=0;j<arguments.length;j++){ n=Math.max(parseInt(this.z(document.getElementById(arguments[j]),"paddingTop")),n); ar=Math.max(parseInt(this.z(document.getElementById(arguments[j]),"paddingBottom")),ar); m=Math.max(parseInt(document.getElementById(arguments[j]).offsetHeight),m); document.getElementById(arguments[j]).style.height=m-n-ar+"px"; } }}, z: function(o, a){ return o.style[a] ? o.style[a] : window.getComputedStyle ? window.getComputedStyle(o, null)[a] : o.currentStyle[a]; } }; Class.x(100,"main");//填充一些数据,以便演示. Class.y("main","sideBar","sideBar0");//可以添加</script> </body> </html>
第二种:CSS加背景图片
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <style type="text/css"> * { padding:0; margin:0; list-style:none; } html { height:100%; } body { font-family:Verdana, Geneva, sans-serif; font-size:14px; color:#555; height:100%; line-height:26px; } #wrap { width:960px; margin:0px auto; padding-bottom:20px; padding-top:20px; } /*<!--*/ .box, .box_top, .box_bottom { background:url(http://www.14pc.com/14pc_images/2div.gif) no-repeat; overflow:hidden; width:100%; } .box { background-repeat:repeat-y; } .box_top { background-position: -980px 0; height:5px; } .box_bottom { background-position: -1990px 0; height:5px; } /*-->*/ #main { float:right; width:630px; padding:10px; } #sideBar { float:left; width:280px; padding:10px; } </style> </head> <body> <div id="wrap"> <div class="box_top"></div> <div class="box"> <p id="sideBar"></p> <p id="main">fasdfdfasd<br /> fasdfdfasd<br /> fasdfdfasd<br /> fasdfdfasd<br /> fasdfdfasd<br /> fasdfdfasd<br /> fasdfdfasd<br /> fasdfdfasd<br /> </p> </div> <div class="box_bottom"></div> </div> </body> </html>
订阅此文章
相关评论(
共0条
)
暂无评论
分类
»JavaScript(
16
)
»Sql(
1
)
»Java(
1
)
»Html/Css(
20
)
»读书笔记(
9
)
»其它(
3
)
最新文章
»HTML中DTD里的一些事儿(二)
»XHTML1.0的几个注意(一)
»HTML中DTD里的一些事儿
»lang="gb2312"是错误的.
»关于"字体"的一些事儿
»查询数据库里的一段数据
»闭包笔记(一)
»定位中用absolute实现fix效果(支持IE6)
»JavaScript词汇表(Glossary)
»Object.prototype.toString
»不定宽度的水平居中
»条件注释的一点小理解---[if ! IE]
»网页head标签里的一些知识
»让IE也支持HTMLElement
»专门IE6中png的透明(滤镜方法)
最新回复
jim@不定宽度的水平居中»
simaopig@关于我的blog»
simaopig@网页head标签里的一些知识»
三思@网页head标签里的一些知识»
三思@让IE也支持HTMLElement»
stri@调查评分代码»
stri@一个效果中遇到的问题»
sunthink@一个效果中遇到的问题»
walkingp@图片轮换»
walkingp@javascript面向对象(二)»
良师益友
»aitom
»愚人码头
»javascript森林
»三思
»蓝色理想
»w3school
»邱少的博客
»三石
»He Min
»丸子
»鸭子
»冰剑
»FIFI
日志归档
2010月七月(
5
)
2010月六月(
2
)
2010月五月(
6
)
2010月四月(
2
)
2010月三月(
1
)
2010月二月(
1
)
2010月一月(
2
)
2009月十二月(
1
)
2009月十一月(
3
)
2009月十月(
5
)
2009月九月(
15
)
2009月八月(
7
)