方法一( 推荐 )、是将 potition:absolute 元素的 left 和 right 同时设置为 0,并且设置 margin:0 auto 。 !DOCTYPE htmlhtml lang=enhead meta charset=UTF-8 titlewww.02405.com/title/headstyle #root{ width: 100%; height: 1
正在浏览:position
css中可以用position:absolute实现元素绝对定位,但是这个绝对定位是以document为参照物进行定位的。 如果要实现基于父级元素的绝对定位,那么要设置父元素的position为:relative,示例代码