1.margin的居中对齐操作
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
div {
width: 500px;
height: 200px;
background: red;
margin: 0 auto;
}
</style>
</head>
<body>
<div></div>
</body>
</html>
2.position的左右对齐操作
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
div {
width: 500px;
height: 200px;
background: red;
position: absolute;
left: 0;
}
</style>
</head>
<body>
<div></div>
</body>
</html>
3.float左右对齐
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
div {
width: 500px;
height: 200px;
background: red;
float: left;
}
</style>
</head>
<body>
<div></div>
</body>
</html>