2019独角兽企业重金招聘Python工程师标准>>>
1.<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>center</title>
<style type="text/css">
.p{ position:relative; float:left; left:50%; }
.c{ position:relative; float:left; right:50%; border:1px solid #f00; }
</style>
</head>
<body>
<div>
<div>cccccccc</div>
</div>
</body>
</html>
2.
设置容器的浮动方式为绝对定位
然后确定容器的宽高 比如宽500 高 300 的层
然后设置层的外边距
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>center</title>
<style type="text/css">
.p{ position:relative; float:left; left:50%; }
.c{ position:relative; float:left; right:50%; border:1px solid #f00; }
.p1{ position:relative; }
.c1{ position:absolute; width:500px; height:300px; top:50%; left:50%; margin:-150px 0 0 -250px; background:#000;}
</style>
</head>
<body>
<div>
<div>cccccccc</div>
</div>
<div>
<div>c1c1c1c1c1c1</div>
</div>
</body>
</html>