行内元素
<style>
span {
/* position: absolute; */
width: 200px;
height: 200px;
background-color: pink;
}
</style>
</head>
<body>
<span>123</span>
</body>
1. 行内元素添加绝对/固定定位,可以直接设置宽度和高度
<style>
span {
position: absolute;
width: 200px;
height: 200px;
background-color: pink;
}
</style>
</head>
<body>
<span>123</span>
</body>
2. 块级元素添加绝对/固定定位,如果不给宽度或者高度,默认大小是内容的大小
3. 浮动元素,绝对,固定定位元素脱离标准流,不会触发外边距合并的问题