block块中文字的上下居中:设置完height后文字本身的line-height属性设为同一数值;
block块中文字的左右居中:不设置width属性,而padding的左右设置为0,上下设置数值,如设置为0 10px(10可以换成其他数);
在设置position:absolute之前,其父级元素设置为position:relative;之后,设定top和left的值以精确定位
小三角块的代码实现:
div{
position: absolute;
width: 0;
height: 0;
overflow: hidden;
border: 7px solid transparent;
border-top-color: #2DCB70;
} border最后一个属性设置为transparent,三角向下设置border-top-color,向上设置bottom,向左设置right,向右设置left |