[练习]如何用CSS进行网页布局

如何用CSS进行网页布局

(最终解释权归原作者所有,侵权必究)

1、版式布局:网页UI设计师将有限的视觉元素进行有机的排列组合,将理性的思维个性化地表现出来,是一种具有个人风格和艺术特色的传达方式,传达信息的同时,也产生感官上的美感。

2、网页设计的特点:网页可以自适应宽度,网页的长度理论上没有限制。

3、分栏又称为分列,常见的布局分为:一列布局,两列布局,三列布局,混合布局。

4、一列布局通常作为网站的首页,简单明了,主题突出,不适合放置多行文字

<!DOCTYPE html PUBLIC "-//W3C//DTDXHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<htmlxmlns="http://www.w3.org/1999/xhtml">

<head>

<metahttp-equiv="Content-Type" content="text/html;charset=utf-8" />

<title>一列布局</title>

<style type="text/css">

body{ margin:0; padding:0; font-size:30px}

div{ text-align:center; font-weight:bold}

.main,.footer{ width:960px;margin:0 auto}

.head{ width:100%; height:100px;background:#ccc}

.main{ height:600px; background:#FCC}

.footer{ height:50px; background:#9CF}

</style>

</head>

 

<body>

<divclass="head">head</div>

<divclass="main">main</div>

<divclass="footer">footer</div>

</body>

</html>

5、两列布局(浮动)

<!DOCTYPE html PUBLIC "-//W3C//DTDXHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<metahttp-equiv="Content-Type" content="text/html;charset=utf-8" />

<title>二列布局</title>

<style type="text/css">

body{ margin:0; padding:0; font-size:30px;font-weight:bold}

div{ text-align:center; line-height:50px}

.main{ width:960px; height:600px; margin:0auto}

.left{ width:300px; height:600px;background:#ccc; float:left;}/*左浮动样式*/

.right{ width:660px; height:600px;background:#FCC; float:right;}/*右浮动样式*/

</style>

</head>

 

<body>

<div class="main">

   <div class="left">left</div>

   <div class="right">right</div>

</div>

</body>

</html>

6、三列布局(定位)

<!DOCTYPE html PUBLIC "-//W3C//DTDXHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<htmlxmlns="http://www.w3.org/1999/xhtml">

<head>

<metahttp-equiv="Content-Type" content="text/html;charset=utf-8" />

<title>二列布局</title>

<style type="text/css">

body{ margin:0; padding:0; font-size:30px;font-weight:bold}

div{ text-align:center; line-height:50px}

.main{ width:960px; height:600px; margin:0auto}

.left{ width:300px; height:600px;background:#ccc; float:left;}/*左浮动样式*/

.right{ width:660px; height:600px;background:#FCC; float:right;}/*右浮动样式*/

</style>

</head>

 

<body>

<div class="main">

   <div class="left">left</div>

   <div class="right">right</div>

</div>

</body>

</html>

7、布局实际上就是块与块间的关系:块挨着块、块嵌套块、块叠压着块

8、混合布局

<!DOCTYPE html PUBLIC "-//W3C//DTDXHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<htmlxmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type"content="text/html; charset=utf-8" />

<title>混合布局编程挑战</title>

<style type="text/css">

body{ margin:0; padding:0; font-size:30px;color:#fff}

.top{width:100%;height:50px;background-color:gray;}

.main{width:100%;height:300px;background-color:red;}

.left{width:200px;height:300px;background-color:blue;float:left;}

.right{width:300px;height:300px;background-color:green;float:right;}

.foot{width:100%;height:50px;background-color:#369}

</style>

 

</head>

 

<body>

<divclass="top">top</div>

<div class="main">

   <div class="right">right</div>

   <div class="left">left</div>

</div>

<divclass="foot">foot</div>

 

</body>

</html>

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值