有时候总要在这里卡好久 气晕
- 如果想让一个图片在一个view里面垂直居中,只需这一步
- 在父容器里加
display:flex;align-items: center;
- 如果要实现水平居中的话,只需要在加一句
justify-content: center;
.containera .artical .pic{
display: flex;
align-items: center;
width: 250rpx;
background-color:rgb(20, 197, 197) ;
}
.containera .artical .pic image{
width: 250rpx;
height: 140rpx;
}
如图:让图片在蓝色那一栏实现垂直居中。