暑期学习日记20:CSS布局

1.网站通常分为页眉、菜单、内容和页脚

(1)页眉(header)通常位于网站顶部(或顶部导航菜单的正下方)。它通常包含徽标(logo)或网站名称

(2)导航栏包含链接列表,以帮助访问者浏览您的网站:

(3)内容部分主要有有1列布局(通常用于移动浏览器)2列布局(通常用于平板电脑和笔记本电脑)3列布局 (仅用于台式机)

(4)页脚位于页面底部。它通常包含诸如版权和联系方式之类的信息

如:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>CSS布局</title>
<style>
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
.header {
  background-color: #f1f1f1;
  padding: 20px;
  text-align: center;
}
.daohang {
  overflow: hidden;
  background-color: #333;
}
.daohang a {
  float: left;
  display: block;
  color: #f2f2f2;
  text-align: center;
  padding: 15px;
  text-decoration: none;
}
.daohang a:hover {
  background-color: #ddd;
  color: black;
}
.column {
  float: left;
  padding: 10px;
  width: 33%;
}
.row:after {
  content: "";
  display: table;
  clear: both;
}
.footer {
  background-color: #f1f1f1;
  padding: 10px;
  text-align: center;
}
</style>
</head>
<body>
<div class="header">
  <h1>页眉</h1>
</div>
<div class="daohang">
  <a href="#">首页</a>
  <a href="#">Link</a>
  <a href="#">Link</a>
</div>

<div class="row">
  <div class="column">
    <h2>内容1</h2>
    <p>内容1</p>
  </div>
  
  <div class="column">
    <h2>内容2</h2>
	<p>内容2<br>
		内容2<br>
		内容2<br>
		内容2<br>
		内容2<br>
		内容2<br>
		内容2<br>
		内容2<br>
		内容2<br>
		内容2<br>
		内容2<br>
		内容2<br>
		内容2<br>
		内容2<br>
		内容2<br>
		内容2<br>
		内容2<br>
		内容2<br>
	  </p>
  </div>
  <div class="column">
    <h2>内容3</h2>
    <p>内容3</p>
  </div>
</div>
<div class="footer">
  <p>页脚</p>
</div>
</body>
</html>

显示效果为:

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值