<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<!-- CSS属性操作三
1、position
-->
<!-- position
1、position 属性规定元素的定位类型。
2、absolute:生成绝对定位的元素,相对于非static定位第一个父元素进行定位。元素的位置通过 "left", "top", "right" 以及 "bottom" 属性进行规定。
3、fixed:生成绝对定位的元素,相对于浏览器窗口进行定位。元素的位置通过 "left", "top", "right" 以及 "bottom" 属性进行规定。
4、relative:生成相对定位的元素,相对于其正常位置进行定位。因此,"left:20" 会向元素的 LEFT 位置添加 20 像素。
5、static 默认值。没有定位,元素出现在正常的流中(忽略 top, bottom, left, right 或者 z-index 声明)。
6、inherit 规定应该从父元素继承 position 属性的值。
-->
<div style="height: 1500px;background-color: coral"></div>
<div style="height: 1500px;background-color: purple"></div>
<div style="width: 100px;height: 100px;background-color: red;position: absolute;top: 100px;right: 100px">absolute定位</div>
<a style="background-color: skyblue;position: fixed;bottom: 20px;right: 20px">fixed定位</a>
<div style="width: 100px;height: 100px;background-color: yellow;position: relative;left: 100px;top: 100px">relative定位</div>
</body>
</html>
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。