【定位写法】
position: absolute;
top: 30px;
left: 20px;
/*位偏移 top bottom left right*/
3.固定定位
【定位导读】
以浏览器的可视窗口来移动
和父元素有关系
不随着滚动条而滚动
不占有原来的位置
【固定写法】
position: fixed;
top: 300px;
right: 30px;
/*位偏移 top bottom left right*/
【右侧版心写法】
position: fixed;
left: 50%;
margin-left: 450px;
/*再移动盒子的宽的一半*/
4.粘性定位
【定位导读】
以浏览器的可视窗口为参照点 ,
【定位写法】
position: relative;
top: 300px;
left: 30px;
/*位偏移 top bottom left right*/
2.绝对定位
【定位导读】
元素移动位置时候,图片和文字
加定位不需要转化,的定位继续保留,的定位后来者居上 ,的定位移动元素(固定定位的的定位特点)
粘性定位占有原先的位置(相对定位的特点)
必须啊添加 top left right bottom 其中一个有效
【粘性定位写法】
position: sticky;
top: 0;
/*部分浏览器不兼容,如果没有父元素或者祖先元素没有定位(浮动也算),的定位
他爸爸没有定位 ,的定位他的的定位位置继续占有
