当前位置: 首页 > news >正文

CSS学习11--版心和布局流程以及几种分布的例子

版心和布局流程

  • 一、版心
  • 二、布局流程
  • 三、一列固定宽度且居中
  • 四、两列左窄右宽
  • 五、通栏平均分布型

一、版心

版心:是指网页主题内容所在的区域。一般在浏览器窗口水平居中位置,常见的宽度值为960px、980px、1000px、1200px等。

二、布局流程

为了提高网页制作的效率,布局时需要遵守一定的布局流程,具体如下:

  • 确定页面版心
  • 分析页面中的行模块,以及每个行模块中的列模块
  • 制作HTML结构
  • CSS初始化,然后开始运用盒子模型的原理,通过CID+CSS布局来控制网页的各个模块

三、一列固定宽度且居中

<html>
	<head>
		<style>
		* {
			padding: 0;
			margin: 0;
		}
		.top,
		.banner,
		.main,
		.footer {
			width: 960px;
			margin: 10px auto;
			text-align: center;
		}
		.top {
			height: 100px;
			background-color: pink;
		}
		.banner {
			height: 120px;
			background-color: skyblue;
		}
		.main {
			height: 500px;
			background-color: red;
		}
		.footer {
			height: 150px;
			background-color: #ccc;
		}
		</style>
	</head>
	<body>
		<div class="top">top</div>
		<div class="banner">banner</div>
		<div class="main">main</div>
		<div class="footer">footer</div>
	</body>
</html>

四、两列左窄右宽

<html>
	<head>
		<style>
		* {
			padding: 0;
			margin: 0;
		}
		.top,
		.banner,
		.main,
		.footer {
			width: 960px;
			margin: 10px auto;
			text-align: center;
		}
		.top {
			height: 100px;
			background-color: pink;
		}
		.banner {
			height: 120px;
			background-color: skyblue;
		}
		.main {
			height: 500px;
			background-color: red;
		}
		.footer {
			height: 150px;
			background-color: #ccc;
		}
		.main .left {
			width: 360px;
			height: 500px;
			float: left;
			background-color: white;
		}
		.main .right {
			width: 590px;
			height: 500px;
			margin-left: 10px;
			float: left;
			background-color: white;
		}
		</style>
	</head>
	<body>
		<div class="top">top</div>
		<div class="banner">banner</div>
		<div class="main">
			<div class="left">left</div>
			<div class="right">right</div>
		</div>
		<div class="footer">footer</div>
	</body>
</html>

五、通栏平均分布型

<html>
	<head>
		<style>
		* {
			padding: 0;
			margin: 0;
		}
		ul {
			list-style: none;
		}
		.top,
		.banner,
		.main,
		.footer {
			width: 960px;
			margin: 10px auto;
			text-align: center;
		}
		.top {
			height: 100px;
			background-color: pink;
		}
		.banner {
			height: 120px;
			background-color: skyblue;
		}
		.main {
			height: 500px;
			background-color: red;
		}
		.footer {
			height: 150px;
			background-color: #ccc;
		}
		.main ul li:nth-child(odd) {
			width: 240px;
			height: 240px;
			background-color: deeppink;
			float: left;
		}
		.main ul li:nth-child(even) {
			width: 240px;
			height: 240px;
			background-color: hotpink;
			float: left;
		}
		</style>
	</head>
	<body>
		<div class="top">top</div>
		<div class="banner">banner</div>
		<div class="main">
			<ul>
				<li>1</li>
				<li>2</li>
				<li>3</li>
				<li>4</li>
			</ul>
		</div>
		<div class="footer">footer</div>
	</body>
</html>

相关文章:

  • 【C++二分查找 拆位法】2411. 按位或最大的最小子数组长度
  • Java | Leetcode Java题解之第390题消除游戏
  • Windows自动化应用程序已启动/未启动,有进程无进程情况-拽起应用程序
  • Percona 开源监控方案 PMM 详解
  • 爆改YOLOv8|利用图像分割网络UNetV2改进yolov8主干-即插即用
  • Modbus-RTU协议
  • 如何将代理IP设置为ISP:详细指南
  • CSP-J选择题专项训练1 -数据结构树
  • 【Linux基础】Linux基本指令(二)
  • pytorch+深度学习实现图像的神经风格迁移
  • IBS和IBD的区别和计算方法介绍
  • MES系统如何支持企业进行数字化转型
  • Elasticsearch 向量数据库本地部署 及操作方法
  • 【HuggingFace Transformers】OpenAIGPTModel源码解析
  • 指针与函数(三)
  • Java项目——苍穹外卖(一)
  • Python--列表简介
  • 数据传输安全——混合加解密(国密)
  • nginx配置负载均衡的几种方式
  • CSP-J基础之进制转换
  • 夜读丨怀念那个写信的年代
  • 学大教育:去年净利润1.797亿元,学习中心增加约60所
  • 泽连斯基公布与特朗普会晤细节,强调实现全面、无条件停火
  • 年客流超2500万,九岁的上海国际旅游度假区有哪些文旅商体实践?
  • 上海经信委:将推动整车企业转型,加强智能驾驶大模型等创新应用
  • 初中女生遭多人侵犯后,家属奔波三年要追责那个“案外”的生物学父亲