使用 CSS 的值自动的 margin 属性的作用
具有自动值的 margin 属性用于水平居中容器内的元素。你可以尝试运行下列代码来实现 margin: auto;
示例
<!DOCTYPE html>
<html>
<head>
<style>
div {
width: 200px;
margin: auto;
border: 2px dashed blue;
}
</style>
</head>
<body>
<p>This is demo text</p>
<div>
This is horizontally centered because it has margin: auto;
</div>
</body>
</html>输出

广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP