Home WeChat Applet Mini Program Development WeChat Mini Program Simple DEMO layout, logic, and style exercises

WeChat Mini Program Simple DEMO layout, logic, and style exercises

Jan 09, 2017 am 10:45 AM

WeChat applet layout example:

The following will be introduced in the following order:

Implementation of layout
Logic implementation
Implementation of styles

1. Implementation of layout

The largest layout is view. The view layout contains: a picture, text description, information bar and dividing line.

<!--最外层-->
<view class="home-view1">
  <!--图片层-->
  <view class="home-view2">
    <image class="home-image1" src="http://qty83k.creatby.com/materials/origin/640e31829b8776967dedc670b5427d0f_origin.jpg"></image>
  </view>
 
  <!--描述层-->
  <text class="home-text1">小巧可爱的案头雅物小巧可爱的案头雅物小巧可爱的案头雅物小巧可爱的案头雅物小巧可爱的案头雅物</text>
 
  <!--信息层-->
  <view class="home-view3"> 
    <view class="home-view4" >
      <image class="home-image-heart" src="http://qty83k.creatby.com/materials/origin/c5656ef00d38d89eae437c5a9102f8fa_origin.png"></image>
 
      <text class="home-text-heart bgColor" > 22</text>
    </view>
    <text class="home-text-time" >2016.10.29</text>
  </view>
 
  <!--分界线line-->
  <view class="home-view-line"></view>
 
 
 
 
 
 
  <!--图片层(下面的代码直接复制了上面的所有布局代码)-->
  <view class="home-view2">
    <image class="home-image1" src="http://qty83k.creatby.com/materials/origin/640e31829b8776967dedc670b5427d0f_origin.jpg"></image>
  </view>
 
  <!--描述层-->
  <text class="home-text1">小巧可爱的案头雅物小巧可爱的案头雅物小巧可爱的案头雅物小巧可爱的案头雅物小巧可爱的案头雅物</text>
 
  <!--信息层-->
  <view class="home-view3"> 
    <view class="home-view4" >
      <image class="home-image-heart" src="http://qty83k.creatby.com/materials/origin/c5656ef00d38d89eae437c5a9102f8fa_origin.png"></image>
 
      <text class="home-text-heart bgColor" > 22</text>
    </view>
    <text class="home-text-time" >2016.10.29</text>
  </view>
 
  <!--分界线line-->
  <view class="home-view-line"></view>
 
</view>
Copy after login

2. Implementation of logic

Just registered the Page interface

Page({
 
  data:{
 
  }
 
})
Copy after login

3. Implementation of styles

.home-view1 style: display specifies that the maximum View layout is a flexible layout, justify-content specifies that the content is centered and arranged vertically, …

.home-view3 style: display stipulates that the information bar layout is a flexible layout, and justify-content stipulates that the content is evenly distributed horizontally.

.home-view4 style: display specifies that the parent layout of collection pictures and collection numbers is a flexible layout, and align-items specifies that the content is centered in the vertical direction.

.home-image1 style: specifies the height of the image

.home-image-heart style: specifies the size of the collected pictures

.home-text1 style: specifies the style of the description text, text-align specifies the text to be centered, line-height specifies the height between two lines of text

.home-text-heart style: specifies the style of the collection number, border-radius specifies the border rounded corners

.home-view-line style: is a dividing line

.bgColor style: Specifies the background of the collection number

.home-view1{
  display: flex;
  justify-content: center;
  flex-direction: column;
 
  height: 100%;
  width: 100%;
  margin: 6px;
 
}
 
.home-view3{
  display: flex;
  justify-content: space-between;
}
 
.home-view4{
  display: flex;
  align-items: center;
}
 
.home-image1{
  height: 200px;
}
 
.home-image-heart{
  width: 30px;
  height: 30px;
}
 
.home-text1{
  text-align: left;
  line-height: 25px;
  margin-top: 6px;
  margin-right: 6px;
  color: gray;
}
 
.home-text-heart{
  width: 22px;
  height: 22px;
  margin-left: 10px;
  border-radius: 20%;
  pad: 5px;
  text-align: center;
}
 
.home-text-time{
  text-align: center;
  margin-right: 20px;
  padding-top: 5px;
  color: gray;
}
 
.home-view-line{
 
 width: 100%;
 height: 6px;
 margin-top: 5px;
 background-color: gainsboro;
}
 
.bgColor{
  background-color: lightblue;
  opacity: 0.6;
}
Copy after login

Thanks for reading, I hope this helps everyone, and thank you for your support of this site!

For more articles related to WeChat applet simple DEMO layout, logic, and style exercises, please pay attention to the PHP Chinese website!


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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)