一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

css 自适应高度的两列页面布局实现方法

时间:2022-06-25 10:13:32 编辑:袖梨 来源:一聚教程网

最大宽度的样式

通过将 “margin: 1em 5%” 修改为 “margin: 0” 可以很容易的切换到最大宽度的样式

 

 代码如下 复制代码
#container
{
margin: 0; /* changed from 1em 5% */
background-color: #FFF;
background-image: url(background.jpg);
background-repeat: repeat-y;
border: 1px solid #333;
}


右侧导航的样式

通过修改 nav 为 float: right ,然后将背景图片右对齐,我们很容易的切换到右侧导航的样式。

 

 代码如下 复制代码
#container
{
margin: 1em 5%;
background-color: #FFF;
background-image: url(background.jpg);
background-repeat: repeat-y;
border: 1px solid #333;
background-position: right; /* ADD THIS RULE */
}
 
#nav
{
float: right; /* WAS FLOAT LEFT */
width: 160px;
margin-right: 10px; /* WAS MARGIN-LEFT */
padding-top: 1em;
}
 
#content
{
padding-top: 1em;
margin: 0 200px 0 2em; /* SWAP ORDER */
}

实例

 代码如下 复制代码

http://www.111com.net> lang="en"> http-equiv="content-type" content="text/html; charset=iso-8859-1">自适应高度的两列页面布局(Two columns with colour) – 示例12 | CodeBit.cn


id="container"> id="banner">

Site name

id="nav">

Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod.

Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod.

Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod.

id="content">

Page heading

Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.

id="footer"> Footer stuff here

 


 

 

 

 

 

 

 

 

热门栏目