水平居中
1.行盒,行块盒居中
设置父元素text-align: center;
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<style>
div{
margin : 30px;
background: lightblue;
height : 100px;
text-align : center;
}
</style>
<body>
<div>
<a href="">.......................</a>
</div>
</body>
</html>
2.常规流块盒
定宽 width:1000px;
margin-left,margin-right:设置为auto
3.绝对定位元素水平居中
定宽 width:1000px;
left : 0; right : 0;
margin-left,margin-right:设置为auto
垂直居中
1.单行文本的垂直居中
line-height: 包含块的高度
260

被折叠的 条评论
为什么被折叠?



