分享

Breaking Out of the Box With CSS Layouts ? Si...

 惊讶空间 2011-10-16

Breaking Out of the Box With CSS Layouts

By | | CSS Tutorials

#wrap {    
 background: url(wrap.gif) repeat-x;    
}

And here’s the final CSS:

* {    
 margin: 0;    
 padding: 0;    
}    
body {    
 background: #eee url(bg.gif) 0 100% repeat-x;    
 font: 12px/18px "Lucida Grande", Verdana, sans-serif;    
 text-align: center;    
 color: #333;    
}    
a:link, a:visited {    
 color: #633;    
}    
a:hover {    
 color: #966;    
}    
h1 {    
 margin-bottom: 11px;    
 margin-left: -108px;    
 padding: 15px 0 21px 108px;    
 border-bottom: 1px solid #ccc;    
 font: normal italic 1.5em/18px Georgia, serif;    
 color: #633;    
}    
h2, h3{    
 font-weight: normal;    
 font-size: 1em;    
 line-height: 18px;    
}    
h2 {    
 margin-left: -204px;    
 padding: 10px 0 20px 204px;    
 background: url(h2_ornament.gif) 3px 0 no-repeat;    
 font-size: 1.25em;    
 text-transform: uppercase;    
 color: #999;    
}    
h3 {    
 padding-bottom: 6px;    
 font-weight: bold;    
 text-transform: uppercase;    
 letter-spacing: -1px;    
 color: #633;    
}    
#wrap {    
 background: url(wrap.gif) repeat-x;    
}    
#page {    
 margin: 0 auto;    
 width: 960px;    
 background: #fff url(page.gif) repeat-y;    
 text-align: left;    
}    
#header {    
 height: 192px;    
 background: #966 url(header.gif) bottom no-repeat;    
}    
#header p {    
 float: left;    
 padding: 60px 24px 24px 126px;    
 font-size: 1.5em;    
 line-height: 1em;    
 color: #fff;    
}    
#header ul {    
 padding-top: 62px;    
 padding-right: 12px;    
 text-align: right;    
 list-style: none;    
}    
#header li {    
 display: inline;    
 margin: 0 12px;    
}    
#header li a {    
 font-size: 1.25em;    
 line-height: 1em;    
 text-decoration: none;    
 color: #fff;    
}    
#header li a:hover {    
 color: #300;    
}    
#content-primary {    
 float: right;    
 margin: 12px 24px 60px 24px;    
 width: 528px;    
}    
#content-primary p {    
 padding-bottom: 18px;    
}    
#content-primary img {    
 float: left;    
 margin: -6px 18px 0 -114px;    
 padding: 3px;    
 border: 3px solid #eee;    
 background: #fff;    
}    
#content-secondary {    
 float: right;    
 margin: 30px 216px 60px 24px;    
 width: 144px;    
 font-size: 11px;    
 color: #300;    
}    
#content-secondary p {    
 padding-bottom: 18px;    
}    
#footer {    
 clear: right;    
 height: 192px;    
 background: #333 url(footer.gif) top no-repeat;    
 font-size: 10px;    
 line-height: 1em;    
 text-shadow: 1px 1px 1px #333;    
 color: #fff;    
}    
#footer a:link, #footer a:visited {    
 color: #c99;    
}        
#footer p {    
 padding: 132px 24px 0 24px;    
}    
.clear {    
 clear: both;    
}

Here’s the result:

1568_image11

Taking it Further

A lot more can be done to "break out of the box". You can get much more experimental with your background images, or go a little crazy with margins — both of which are explored in detail in The Art & Science of CSS, on which I was a co-author. While what we’ve discussed here was definitely a minimal approach, hopefully it will get you thinking of fun things you can try (and move beyond the thinking that CSS designs have to be boring). So have fun with it. Check out the book, as well as some of my favorite sites that use fun box-breaking techniques:

Apple iPod Shuffle: I really like the iPod shuffle and headphones that appear to be "peeking" out from behind the container.

1568_image12

Tingsek: I’m a big fan of horizontal "bars" that fill the entire screen — I think it’s a great way to avoid a totally contained, boxy feeling. The post-it note’s angle also helps break the design up a bit, along with the background photo of Tingsek.

1568_image13

CSS Zen Garden, Entry #194: Background images really help this layout to avoid feeling boxy, even though it follows a basic grid.

1568_image14

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多