三角形
1. 等腰三角形
width: 0;
border: 10px solid transparent;
border-bottom-color: tomato;
position: absolute;
width: 0;
border: 10px solid transparent;
border-left-color: tomato;
2. 直角三角形
width: 0;
border-top:20px solid transparent;
border-right:20px solid coral;
border-color: transparent coral transparent transparent;
border-style: solid;
border-width: 50px 25px 0 0;
水平垂直居中
1. absolute + transform
.outer {
position: relative
}
.inner {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
2. flex
.outer {
display: flex;
justify-content: center;
align-items: center;
}
3. flex + margin: auto
.outer {
display: flex;
}
.inner {
margin: auto;
}
4. table
.inner {
display: table-cell;
vertical-align: middle;
text-align: center;
}
借鉴:不吃茶的李白.