### [微信小程序中怎么让图片居中](https://www.prosaas.cn/article/16846) **Published:** 2020-03-23T02:07:55 **Author:** 5201314 **Excerpt:** 微信小程序中怎么让图片居中小程序中让图片居中主要是写wxss(css)样式来实现,实现方式是设置父组件disp… ![](https://img.php.cn/upload/article/000/000/040/5e78192e88925367.jpg) **微信小程序中怎么让图片居中** 小程序中让图片居中主要是写wxss(css)样式来实现,实现方式是设置父组件display为flexbox,并添加justify-content: center;和align-items:center;让元素在水平方向和垂直方向居中即可。 推荐学习:小程序开发 **具体实现方式如下:** 1、首先编写wxml文件,添加一张图片  2、然后编写wxss文件,给图片及其父元素添加样式 page{ height:100% } .imagesize{ display:flex; //flex布局 justify-content: center; //水平轴线居中 align-items:center; //垂直居中 } .imagesize image { width:400rpx; height:400rpx; } 3、效果如下 ![](https://img.php.cn/upload/image/857/877/496/1584929034472515.png) PHP中文网,大量navicat教程,欢迎学习! 以上就是微信小程序中怎么让图片居中的详细内容,更多请关注知企PROSAAS其它相关文章! **Tags:** css, display, navicat, php, 微信小程序 **Categories:** 后端开发 ---