How to center pictures in WeChat mini program

angryTom
Release: 2020-03-23 10:07:55
Original
32943 people have browsed it

How to center pictures in WeChat mini program

How to center the picture in the WeChat mini program

The main way to center the picture in the mini program is to write wxss (css) style to achieve it. The method is to set the parent component display to flexbox, and add justify-content: center; and align-items: center; to center the element horizontally and vertically.

Recommended learning: Small program development

The specific implementation method is as follows:

1. First write the wxml file and add a Picture

<view class=&#39;imagesize&#39;>
  <image src="/images/2.png" class=&#39;in-image&#39;   >
  </image>
</view>
Copy after login

2. Then write the wxss file and add styles to the picture and its parent elements

page{
   height:100%
}
.imagesize{
 display:flex;                    //flex布局
 justify-content: center;         //水平轴线居中
 align-items:center;                //垂直居中
}
.imagesize image { 
  width:400rpx;
  height:400rpx;
}
Copy after login

3. The effect is as follows

How to center pictures in WeChat mini program

PHP Chinese website, a large number of navicat tutorials, welcome to learn!

The above is the detailed content of How to center pictures in WeChat mini program. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template