

12 3 I'm an element that is block-like with my siblings and we're centered in a row. 4 5 6 I'm an element that is block-like with my siblings and we're centered in a row. I have more content in me than my siblings do. 7 8 9 I'm an element that is block-like with my siblings and we're centered in a row.10 11
12 3 I'm an element that is block-like with my siblings and we're centered in a row. 4 5 6 I'm an element that is block-like with my siblings and we're centered in a row. I have more content in me than my siblings do. 7 8 9 I'm an element that is block-like with my siblings and we're centered in a row.10 11
1 body { 2 background: #f06d06; 3 font-size: 80%; 4 } 5 main { 6 background: white; 7 margin: 20px 0; 8 padding: 10px; 9 }10 main div {11 background: black;12 color: white;13 padding: 15px;14 max-width: 125px;15 margin: 5px;16 }17 .inline-block-center {18 text-align: center;19 }20 .inline-block-center div {21 display: inline-block;22 text-align: left;23 }24 .flex-center {25 display: flex;26 justify-content: center;27 }垂直居中:
方法1:设置padding-top和padding-bottom的值相等
方法2:设置height和line-height的值相等
方法3:固定高度可以有一种处理方式position:absolute;top:50%;height:100px;margin-top:-50px;如果高度不固定,也可以使用js动态获取高度来。
还有css3的一些属性,考虑到兼容性问题不在叙述。
