最大宽度的样式
通过将 “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 */ } |
实例
代码如下 | 复制代码 |
lang="en">
http-equiv="content-type" content="text/html; charset=iso-8859-1">
Site nameid="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 headingUt 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 |