分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 网页技术

css简单布局

发布时间:2023-09-06 01:28责任编辑:顾先生关键词:暂无标签

一列布局

宽度未定义则宽度为通栏的宽度

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>一列布局</title>
<style>
div{text-align: center;}
.head{height: 100px;background-color:red;}
.main{margin: 0 auto;height:500px;background-color:yellow;width: 80%;}
.foot{margin: 0 auto;background-color:blue;width:80%;}
</style>
</head>
<body>
<div class="head">head</div>
<div class="main">main</div>
<div class="foot">foot</div>
</body>
</html>

两列布局

<!--利用浮动或绝对定位去除文档样式-->

<!DOCTYPE html>
<html>
<head>
<title>二列布局</title>
<style>
body{ margin:0; padding:0; font-size:30px; font-weight:bold}
div{ text-align:center; line-height:50px}
.main{ width:80%; height:600px; margin:0 auto}
.left{ width:20%; height:600px; background:#ccc; float:left}
.right{ width:80%; 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>

三列布局

<!--CSS中的 margin 和 padding 都是顺时钟方向进行定义的-->

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>三列布局</title>
<style type="text/css">
body{ margin:0; padding:0; ?font-weight:bold}
div{ line-height:50px}
.left{ width:200px; height:600px; background:#ccc; position: absolute; left:0; top:0}
.main{ height:600px; margin:0 310px 0 210px; background:#9CF}
.right{ height:600px; width:300px; position:absolute; top:0;right:0;; background:#FCC;}
</style>
</head>
<body>
???<div class="left">left</div>
???<div class="main">main</div>
???<div class="right">right</div>
</body>
</html>

css简单布局

原文地址:http://www.cnblogs.com/1001n/p/7953964.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved