盒模型拓展居中
3.居中
关于居中:主要有2种,一种关于盒子,一种关于文字
水平居中:
使用text-align:center
单行文字的垂直居中,设置line-height的高度和盒子一样高
如果需要设置文本水平垂直都居中
```
设置 text-align:center;
ine-height;盒子的高度
```
代码:
```
div{
width:100px;
height:100px;
background-color:red;
text-align:center;
line-height:100px;
}
<div>
<p>你好我是</p>
</div>
```
效果:

<br/>
如果是多行文本设置垂直居中不能使用行高等于盒子高
方法:盒子不设置高度,设置上下相同的padding 属性值
```
.diva{
width:100px;
border:2pxsolidred;
text-align:center;
padding:30px,0px;
}
```
效果:

- 简介
- 文字三属性(颜色,字号,字体)
- 盒子三属性(width , height, background-color)
- CSS引入方法
- CSS选择器
- css高级选择器
- CSS的继承性
- 颜色属性color
- 字体font-family
- 字号font-size
- 文字在盒子行高 line-height
- 字体加粗font-weight
- 字体样式font-style
- 文本段落对齐text-align
- 文字修饰(上划线下划线中划线 text-decoration)
- 文字缩进text-indent
- 盒子模型的宽度与高度width,height
- 内边距padding
- 边框border
- 外边距margin
- 清除默认样式
- 盒子height高度属性拓展
- 文字在盒子里居中text-align:center
- 盒子在盒子里的水平居中
- margin塌陷
- 标准文档流display
- 浮动float
- 浮动元素性质
- 浮动贴边原理
- 浮动元素的标准流问题(文字围边效果)
- 清除浮动
- 清除浮动影响二: clear属性
- 清除浮动overflow方法
- 伪类标签
- background-color背景颜色属性
- background-image 背景图片调用
- background-repeat 背景图平铺状态
- background-position背景定位
- background-attachment背景附着
- background综合语法
- 相对定位position:relative
- 绝对定位position:absolute
- 定位压盖顺序
- CSS制作LOGO超链接妙招
- CSS公共类的继承性
- em单位
- 媒体查询
- flex布局