最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
css中三种绝对定位元素的水平垂直居中的方法
时间:2016-12-23 00:00:00 编辑:简简单单 来源:一聚教程网
1.css实现居中
缺点:需要提前知道元素的宽度和高度。
.box{ width: 600px; height: 400px; position: absolute; left: 50%; top: 50%; border:1px solid #000; background:red; margin-top: -200px; /* 高度的一半 */ margin-left: -300px; /* 宽度的一半 */ } |