html css 布局

对于初学者来说, 使用css进行网页布局不是一件容易的事. css 的布局方式总是让我觉得它不是一种很好的布局方式, 但却又是如此的广泛流行(呵呵, 可能菜鸟才这么认为的). 有时候看到某个网站做得很不错, 就想看看是怎么布局, 结果一查看网页的源代码, 代码多且乱, 基本上都是复杂得看不明白的. 这无疑是基础没打好的原因. 今天再次重温了一次w3cshool上css部队的内容, 把其中一个简单而且普遍的布局给拿了下来, 以备不时之需.

 

<html>
<head>
<style type="text/css">
div.container
{
width
:100%;
margin
:0px;
border
:1px solid gray;
line-height
:150%;
}
div.header,div.footer
{
padding
:0.5em;
color
:white;
background-color
:gray;
clear
:left;
}
h1.header
{
padding
:0;
margin
:0;
}
div.left
{
float
:left;
width
:160px;
margin
:0;
padding
:1em;
}
div.content
{
margin-left
:190px;
border-left
:1px solid gray;
padding
:1em;
}
</style>
</head>
<body>

<div class="container">

<div class="header"><h1 class="header">W3School.com.cn</h1></div>

<div class="left"><p>"Never increase, beyond what is necessary, the number of entities required to explain anything." William of Ockham (1285-1349)</p></div>

<div class="content">
<h2>Free Web Building Tutorials</h2>
<p>At W3School.com.cn you will find all the Web-building tutorials you need,
from basic HTML and XHTML to advanced XML, XSL, Multimedia and WAP.
</p>
<p>W3School.com.cn - The Largest Web Developers Site On The Net!</p></div>

<div class="footer">Copyright 2008 by YingKe Investment.</div>
</div>

</body>
</html>

posted on 2011-05-23 18:10  Jacken  阅读(2826)  评论(0)    收藏  举报

导航