<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>11.fixed</title>
<style>
*{
margin: 0;
padding: 0;
}
.fixed{
position: fixed;
width: 300px;
height: 300px;
left: 0;
top: 0;
background: greenyellow;
display: flex;
justify-content: center;
align-items: center;
font-weight: bold;
font-size: 50px;
}
</style>
</head>
<body>
<div class="fixed">
把我固定
</div>
</body>
</html>
复制代码
position:fixed(相对于视窗来定位、一个固定定位元素不会保留它原本在页面应有的空隙(脱离文档流))...
最新推荐文章于 2023-08-29 14:37:30 发布