Blogger Information
Blog 250
fans 3
comment 0
visits 321058
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
2018/03/26(绝对定位)
梁凯达的博客
Original
732 people have browsed it

重点:

          绝对定位是令元素脱离了文档流并且使行内元素支持宽高的一种定位方式。

定位写法: 

          position: absolute;

注意:

         脱离文档流结构之后,整个定位中的块会出现塌陷,同时脱离了文档流,且支持宽高的设定。

案例:

QQ截图20180401155523.png

代码部分:

实例

<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<meta http-equiv="X-UA-Compatible" content="ie=edge" />
	<title>Document</title>
	<style>
		.box{
			height: 700px;
			width: 700px;
			background: yellow;
			position: absolute;
			left: 0;
			top: 0;			
		}
		.box1{
			height: 200px;
			width: 200px;
			background: black;
			position: absolute;
			top:200px;
		}
		.box2{
			height: 200px;
			width: 200px;
			background: blueviolet;
			position: absolute;
			left: 200px;
			top: 400px;
		}
		.box3{
			height: 200px;
			width: 200px;
			background: brown;
			position: absolute;
			left: 400px;
			top: 200px;
			
		}
		.box4{
			height: 200px;
			width: 200px;
			background: lightcoral;
			position: absolute;
			left: 200px;
		}
	</style>
</head>
<body>
	 <div class="box">
	 	<div class="box1"></div>
	 	<div class="box2"></div>
	 	<div class="box3"></div>
	 	<div class="box4"></div>
	 	<div class="box5"></div>
	 </div>
</body>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例


Correction status:Uncorrected

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!