【微信小程序开发小白零基础入门】微信小程序框架演示【建议收藏】

微信小程序框架演示


一、容器属性

1.flex-direction的用法

flex-direction.wxml
<view class='title'>1.flex-direction的用法</view>
<view class='myContainer'>
  <view class='demo'></view>
  <view class='demo'></view>
  <view class='demo'></view>
</view>
flex-direction.wxss
.myContainer {
    
    
  margin: 80rpx auto;
  width: 600rpx;
  height: 500rpx;
  border: 1px solid silver;
  display: flex;
  flex-direction: column-reverse; /*自行更换成row-reverse, column,column-reverse试试*/
}
.demo {
    
    
  width: 100px;
  height: 100rpx;
  line-height: 100rpx;
  margin: 15rpx; 
  text-align: center;
  background-color: lightgreen;
}

在这里插入图片描述

2.flex-wrap的用法

flex-wrap.wxml
<view class='title'>2.flex-wrap的用法</view>
<view class='myContainer'>
  <view class='demo'></view>
  <view class='demo'></view>
  <view class='demo'></view>
</view>
flex-wrap.wxss
.myContainer {
    
    
  margin: 80rpx auto;
  width: 600rpx;
  height: 500rpx;
  border: 1px solid silver;
  display: flex;
  flex-direction: row; 
  flex-wrap:wrap;/*自行更换成nowrap, wrap-reverse试试*/
}
.demo {
    
    
  width: 100px;
  height: 100rpx;
  line-height: 100rpx;
  margin: 15rpx; 
  text-align: center;
  background-color: lightgreen;
}

在这里插入图片描述

3.justify-content的用法

justify-content.wxml
<view class='title'>3.justify-content的用法</view>
<view class='myContainer'>
  <view class='demo'></view>
  <view class='demo'></view>
  <view class='demo'></view>
</view>
justify-content.wxss
.myContainer {
    
    
  margin: 80rpx auto;
  width: 600rpx;
  height: 500rpx;
  border: 1px solid silver;
  display: flex;
  flex-direction: row;
  justify-content: flex-start; /*换成 flex-end| center| space-between| space-around| space-evenly 试试*/
}

.demo {
    
    
  width: 50px;
  height: 100rpx;
  line-height: 100rpx;
  border: 1px solid;
  text-align: center;
  background-color: lightgreen;
}

在这里插入图片描述

4.align-items的用法

align-items.wxml
<view class='title'>4.align-items的用法</view>
<view class='myContainer'>
  <view class='demo z'></view>
  <view class='demo h'></view>
  <view class='demo y'></view>
</view>
align-items.wxss
.myContainer {
    
    
  margin: 80rpx auto;
  width: 600rpx;
  height: 500rpx;
  border: 1px solid silver;
  display: flex;
  flex-direction: row; 
  align-items: flex-start;/*自行更换成stretch(默认值)| flex-start | center | flex-end | baseline试试*/
}

.demo {
    
    
  height: 100rpx;
  line-height: 100rpx;
  border: 1px solid;
  text-align: center;
  background-color: lightgreen;
}

/*如果align-items取值为stretch,请注释掉以下全部代码*/
.z{
    
    
  width: 200rpx;
}
.h{
    
    
  width: 300rpx;
}
.y{
    
    
  width: 400rpx;
}

在这里插入图片描述

5.align-content的用法

align-content.wxml
<view class='title'>5.align-content的用法</view>
<view class='myContainer'>
  <view class='demo z'></view>
  <view class='demo h'></view>
  <view class='demo y'></view>
  <view class='demo g'></view>
  <view class='demo j'></view>
  <view class='demo x'></view>
</view>
align-content.wxss
.myContainer {
    
    
  margin: 80rpx auto;
  width: 600rpx;
  height: 500rpx;
  border: 1px solid silver;
  display: flex;
  flex-direction: row; 
  flex-wrap: wrap;
  align-content: flex-start;/*自行更换成stretch(默认值) | flex-start | center | flex-end | space-between |space-around | space-evenly试试*/
}

.demo {
    
    
  height: 100rpx;/*如果align-items取值为stretch,请注释掉关于height的代码*/
  line-height: 100rpx;
  border: 1px solid;
  text-align: center;
  background-color: lightgreen;
}


.z{
    
    
  width: 200rpx;
}
.h{
    
    
  width: 300rpx;
}
.y{
    
    
  width: 400rpx;
}
.g{
    
    
  width: 200rpx;
}
.j{
    
    
  width: 300rpx;
}
.x{
    
    
  width: 400rpx;
}

在这里插入图片描述

二、项目属性

1.order的用法

order.wxml
<view class='title'>1.order的用法</view>
<view class='myContainer'>
  <view class='demo z'></view>
  <view class='demo h'></view>
  <view class='demo y'></view>
</view>
order.wxss
.myContainer {
    
    
  margin: 80rpx auto;
  width: 600rpx;
  height: 500rpx;
  border: 1px solid silver;
  display: flex;
  flex-direction: row; 
  flex-wrap:wrap;/*自行更换成nowrap, wrap-reverse试试*/
}
.demo {
    
    
  width: 50px;
  height: 100rpx;
  line-height: 100rpx;
  margin: 15rpx; 
  text-align: center;
  background-color: lightgreen;
}

.z{
    
    
  order: 6;
}
.h{
    
    
  order: -1;
}
.y{
    
    
  order: 2
}

在这里插入图片描述

2.flex-shrink的用法

flex-shrink.wxml
<view class='title'>2.flex-shrink的用法</view>
<view class='myContainer'>
  <view class='demo z'></view>
  <view class='demo h'></view>
  <view class='demo y'></view>
  <view class='demo g'></view>
  <view class='demo j'></view>
  <view class='demo x'></view>
</view>
flex-shrink.wxss
.myContainer {
    
    
  margin: 80rpx auto;
  width: 500rpx;
  height: 500rpx;
  border: 1px solid silver;
  display: flex;
  flex-direction: row; 
}
.demo {
    
    
  height: 100rpx;
  line-height: 100rpx;
  border: 1px solid;
  text-align: center;
  background-color: lightgreen;
}

.z{
    
    
  width: 200rpx;
  flex: 1;
}
.h{
    
    
  width: 200rpx;
  flex: 2;
}
.y{
    
    
  width: 200rpx;
  flex: 3;
}
.g{
    
    
  width: 200rpx;
  flex: 1;
}
.j{
    
    
  width: 200rpx;
  flex: 2;
}
.x{
    
    
  width: 200rpx;
  flex: 3;
}

在这里插入图片描述

3.flex-grow的用法

flex-grow.wxml
<view class='title'>3.flex-grow的用法</view>
<view class='myContainer'>
  <view class='demo z'></view>
  <view class='demo h'></view>
  <view class='demo y'></view>
</view>
flex-grow.wxss
.myContainer {
    
    
  margin: 80rpx auto;
  width: 600rpx;
  height: 500rpx;
  border: 1px solid silver;
  display: flex;
  flex-direction: row; 
}
.demo {
    
    
  height: 100rpx;
  line-height: 100rpx;
  border: 1px solid;
  text-align: center;
  background-color: lightgreen;
}

.z{
    
    
  width: 100rpx;
  flex-grow: 0;
}
.h{
    
    
  width: 100rpx;
  flex-grow: 1;
}
.y{
    
    
  width: 100rpx;
  flex-grow: 2;
}

在这里插入图片描述

4.flex-basis的用法

flex-basis.wxml
<view class='title'>4.flex-basis的用法</view>
<view class='myContainer'>
  <view class='demo g'></view>
  <view class='demo j'></view>
  <view class='demo x'></view>
</view>
flex-basis.wxss
.myContainer {
    
    
  margin: 80rpx auto;
  width: 600rpx;
  height: 500rpx;
  border: 1px solid silver;
  display: flex;
  flex-direction: row; 
}
.demo {
    
    
  height: 100rpx;
  line-height: 100rpx;
  border: 1px solid;
  text-align: center;
  background-color: lightgreen;
}

.g{
    
    
  width: 100rpx;
  flex-grow: 0;
}
.j{
    
    
  width: 100rpx;
  flex-grow: 1;
}
.x{
    
    
  width: 100rpx;
  flex-grow: 2;
}

在这里插入图片描述

5.flex-self的用法

flex-self.wxml
<view class='title'>5.align-self的用法</view>
<view class='myContainer'>
  <view class='demo y'></view>
  <view class='demo g'></view>
  <view class='demo j'></view>
  <view class='demo x'></view>
</view>
flex-self.wxss
.myContainer {
    
    
  margin: 80rpx auto;
  width: 500rpx;
  height: 500rpx;
  border: 1px solid silver;
  display: flex;
  flex-direction: row;
}

.demo {
    
    
  width: 100rpx;
  line-height: 100rpx;
  margin: 15rpx;
  text-align: center;
  background-color: lightgreen;
}

.y {
    
    
  height: 100rpx;
  align-self: flex-start;
}

.g {
    
    
  height: 100rpx;
  align-self: center;
}

.j {
    
    
  height: 100rpx;
  align-self: flex-end;
}

.x {
    
    
  align-self: stretch;
}

在这里插入图片描述

三、推荐小程序(欢迎各位大佬指导)

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_44967475/article/details/120613645