+ -
当前位置:首页 → 问答吧 → 关于一个三列布局的问题!

关于一个三列布局的问题!

时间:2010-06-02

来源:互联网

网站布局结构如下:
中间列(subcenter层)内容高度不固定!有可能高于或者低于两边 (subleft层) 和 (subright层)。
现在需要!不管任何时候!(中间列不管高度是 高于 或者 低于 两边列)
都需要两边的列层的左右边框(红色)的长度能到达bottom层的上面!也就是四条竖线(红色)的高度!任何时候都是等于 center层的高度!

只要能达到效果!四条竖线高度不管任何时候都等于center的高度!可以改变html结构代码!

小弟想了半天实在想不好的办法!跪求优秀的解决办法!能不用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"> * { margin:0; padding:0; } #header { background:#333; width:800px; height:50px; margin:0 auto; color:#fff; } #center { background:#f4efe3; width:800px; margin:0 auto; color:#000; overflow:hidden; } #subcenter { float:left; width:500px; height:500px; } #subleft { width:146px; float:left; border-left:1px solid #f00; border-right:1px solid #f00; } #subright { width:146px; float:left; border-left:1px solid #f00; border-right:1px solid #f00; } #bottom { background:#ccc; width:800px; height:30px; margin:0 auto; color:#fff; clear:both; } </style> </head> <body> <div id="header">header</div> <div id="center"> <div id="subleft"> <div class="leftcon"><p>左边的内容的高度</p><p>左边的内容的高度</p><p>左边的内容的高度</p><p>左边的内容的高度</p><p>左边的内容的高度</p><p>左边的内容的高度</p><p>左边的内容的高度</p><p>左边的内容的高度</p><p>左边的内容的高度</p><p>左边的内容的高度</p><p>左边的内容的高度</p><p>左边的内容的高度</p></div> </div> <div id="subcenter">中间的内容高度不固定</div> <div id="subright"> <div class="rightcon"><p>右边内类容的高度</p><p>右边内类容的高度</p><p>右边内类容的高度</p><p>右边内类容的高度</p><p>右边内类容的高度</p><p>右边内类容的高度</p><p>右边内类容的高度</p></div> </div> </div> <div id="bottom">bottom</div> </body> </html>
 提示:您可以先修改部分代码再运行
[ 本帖最后由 feng192 于 2010-6-2 16:29 编辑 ]

作者: feng192   发布时间: 2010-06-02

版主大哥!在不!快来救命啊!急着用呢!

作者: feng192   发布时间: 2010-06-02

其实最方便最笨蛋的办法就是在center加入一个垂直循环的底图,底图上对应红色的边框线画上一样的线条。

作者: vincentyung   发布时间: 2010-06-02

引用:
原帖由 vincentyung 于 2010-6-2 14:55 发表
其实最方便最笨蛋的办法就是在center加入一个垂直循环的底图,底图上对应红色的边框线画上一样的线条。
有一定的可行性!谢谢!不知道哪位大哥还有更好的办法不!

作者: feng192   发布时间: 2010-06-02

用一个div包裹.center 加上左右边框     中间.subcenter 加上左右边框就可以了.

作者: qq258145840   发布时间: 2010-06-02

引用:
原帖由 qq258145840 于 2010-6-2 16:25 发表
用一个div包裹.center 加上左右边框     中间.subcenter 加上左右边框就可以了.
如果这样! 中间小subcenter内容没左右两列长的时候!是不是会出现中间条竖线不能到达最下面呢!

作者: feng192   发布时间: 2010-06-02

应该就是三列等高吧

作者: ruobilin   发布时间: 2010-06-02

引用:
原帖由 ruobilin 于 2010-6-2 16:31 发表
应该就是三列等高吧
是这意思!我找到了JS实现的办法!但是我希望有找到纯CSS实现的办法!求良方!

作者: feng192   发布时间: 2010-06-02

三列等高用正负边距吧   
#left, #center, #right { margin-bottom:-10000px; padding-bottom:10000px; }

作者: qq258145840   发布时间: 2010-06-02

用背景图不就可以了吗.

作者: 4321285   发布时间: 2010-06-02

楼主想在边框上做文章.

作者: qq258145840   发布时间: 2010-06-02

用背景图是可以啊!我想是在不用图片基础下!只用边框实现!想半天了!没相出好方法来!问题是解决了!我用JS解决的!

作者: feng192   发布时间: 2010-06-02

引用:
原帖由 qq258145840 于 2010-6-2 17:37 发表
三列等高用正负边距吧   
#left, #center, #right { margin-bottom:-10000px; padding-bottom:10000px; }
晚上试试你的说的办法!看看是是否能行!谢谢提供思路!

作者: feng192   发布时间: 2010-06-02