/* 父元素通用样式 */
.containerCommon {
height: 100px;
background-color: gray;
}
/* 子元素通用样式 */
.itemCommon {
width: 80px;
height: 40px;
background-color: black;
color: white;
}
.container-11 {
position: relative;
}
.item-11 {
position: absolute;
left: 50%;
top: 50%;
/*这里不用transform的话,就必须知道子元素宽度,通过margin-left和margin-right进行位移*/
transform: translate(-50%, -50%);
}
.container-12 {
position: relative;
}
.item-12 {
position: absolute;
left: 0;
top: 0;
bottom: 0;
right: 0;
margin: auto;
}
.container-13 {
display: table-cell;
vertical-align: middle;
text-align: center;
width: 200px;
}
.item-13 {
display: inline-block;
color: white;
background-color: black;
/* margin: 0 auto; */
}
.container-14 {
display: flex;
justify-content: center;
align-items: center;
}
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) | 黑马程序员IT技术论坛 X3.2 |