您的位置:首页 > 房产 > 建筑 > 六安新闻 今日 最新消息_公司为什么建立网站_域名查询网站_bt种子bt天堂

六安新闻 今日 最新消息_公司为什么建立网站_域名查询网站_bt种子bt天堂

2024/10/5 15:33:51 来源:https://blog.csdn.net/mengran_code/article/details/142626507  浏览:    关键词:六安新闻 今日 最新消息_公司为什么建立网站_域名查询网站_bt种子bt天堂
六安新闻 今日 最新消息_公司为什么建立网站_域名查询网站_bt种子bt天堂

文章目录

    • 1.左右结构,左边100%;右边宽度固定
    • 2.左右结构,左边固定,右边100%
    • 3.左中右结构,左边固定,右边固定,中间100%

前面有一篇文章讲过 《css实现两列布局,一列固定宽度,一列宽度自适应方法》,主要是讲实现一列固定宽度,一列宽度自适应的几种方法。

下面我在总结一下一般的三种扩展布局,这儿所示的扩展布局很常规,有的童鞋会说使用column或者flex啥的布局不是很方便吗,但是你也要看它的支持程度吧,比如你在手机端使用,那当然很好,那我要兼容IE8,IE9呢?

1.左右结构,左边100%;右边宽度固定

在这里插入图片描述

css代码:

#header{height:80px; background:#CCC;}
#center{overflow:hidden; zoom:1;}
#main_wrapper{float:left; width:100%; margin-top:10px; margin-left:-210px;}
#main{height:200px; margin-left:210px; background:#999;}
#sidebar{float:right; width:200px; margin-top:10px; height:200px; background:#AAA;}
#footer{height:50px; margin-top:10px; background:#CCC;}

HTML代码:

<div id="header"></div>
<div id="center"><div id="main_wrapper"><div id="main"></div></div><div id="sidebar"></div>
</div>
<div id="footer"></div>

2.左右结构,左边固定,右边100%

在这里插入图片描述

css代码:

#header{height:80px; background:#CCC;}
#center{overflow:hidden; zoom:1;}
#sidebar{float:left; width:200px; margin-top:10px; height:200px; background:#AAA;}
#main_wrapper{float:right; width:100%; margin-top:10px; margin-left:-210px;}
#main{height:200px; margin-left:210px; background:#999;}
#footer{height:50px; margin-top:10px; background:#CCC;}

HTML代码:

<div id="header"></div>
<div id="center"><div id="sidebar"></div><div id="main_wrapper"><div id="main"></div></div>
</div>

3.左中右结构,左边固定,右边固定,中间100%

在这里插入图片描述

css代码:

#header{height:80px; background:#CCC;}
#center{overflow:hidden; zoom:1;}
#sidebar-l {float:left; width:200px; margin-top:10px; height:200px; background:#AAA;}
#main-wrapper {margin-top:10px; float:left; width:100%; margin-left:-420px; height:200px;}
#main {margin-left:438px; background:#999; height:200px;}
#sidebar-r {float:right; width:200px; margin-top:10px; height:200px; background:#AAA;}
#footer{height:50px; margin-top:10px; background:#CCC;}

HTML代码:

<div id="header"></div>
<div id="center"><div id="sidebar-l">这里是左边</div><div id="main-wrapper"><div id="main">这里是中间</div></div><div id="sidebar-r">这里是右边</div>
</div>
<div id="footer"></div>

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com