往常我们画一条横线直接用标签
body{ margin-top:100px; margin-left:200px; } .mainp{ width:900px; padding:10px; overflow:hidden; /*关键*/ border:1px solid black; } .leftp{ float:left; width:400px; background-color:#CC6633; } .rightp{ float:right; width:400px; background-color:#CC66FF; } .centerp{ float:left; width:50px; border-right: 1px dashed black; padding-bottom:1600px; /*关键*/ margin-bottom:-1600px; /*关键*/ }
效果图:
function myfun(){ var p1=document.getElementById("content"); var p2=document.getElementById("side"); var h1=p1.offsetHeight; var h2=p2.offsetHeight; if(h1>h2){ p1.style.borderRight="1px dashed #B6AEA3"; }else{ p2.style.borderLeft="1px dashed #B6AEA3"; } }