<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.first {
width:500px;
height: 500px;
/* position: absolute; */
/* position: relative; */
/* top:40px; */
background-color: yellow;
}
.second {
width:300px;
height: 300px;
/*absolute的基点,若父元素设了position不为static,则是父元素的点;若未设,则是网页窗口的点 */
/* position: absolute;*/
/*relative的基点是其static时的点 */
/* position: relative; */
/* fixed的基点是网页窗口 */
position:fixed;
/* sticky是relative和fixed相互转换 */
/* position:sticky; */
top:40px;
background-color: red;
}
</style>
</head>
<body>
<div class = "first">
<div class = "second"></div>
</div>
</body>
</html>```
css 之 poistion 值
最新推荐文章于 2021-06-03 07:54:29 发布