如何使img或者div在div中水平垂直居中显示

如题所述

/* 1: */
img{
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
}

(只能使用CSS方法,不需要高度等其他的,自匹配)

温馨提示:答案为网友推荐,仅供参考
相似回答