【微信小程序】View组件与Flexbox弹性盒模型 字体颜色摆放显示案例,

本文通过微信小程序实例,详细讲解了Flexbox弹性盒模型的使用,包括row和column方向的布局,以及justify-content和align-items的各种对齐方式,如flex-start, flex-end, center, space-between, space-around等,是学习小程序布局的实用教程。" 79664271,977510,Kubernetes上部署Spring Boot应用实战,"['Kubernetes', 'Docker', 'Java', 'Spring Boot', 'Microservices']

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

微信web开发者工具 v0.11.122100

/**index.wxss代码**/
.page
{
  flex: 1;
  background-color: #ffff00;   
  font-size: 16px;
}
.page-section
{
  padding:10px;
  background-color: #fffff0;
  margin:10px;
  font-size:16px;`
}


.flex-item
{
  width :80px;
  height:80px;
}
.bc_green
{
  background-color: #00ff00;
}
.bc_red
{
  background-color: #ff0000;
}
.bc_blue
{
  background-color: #0000f8;
}


<!--index.wxml代码:注意:符号和字母不能填写错误-->

<view class="page">  
  <!--第1段案例:文本显示-->
  <view class="page-section">
    <text>-第1段案例:View Demo</text>
  </view>


  <!--第2段案例:横着显示的代码演示-->
  <view class="page-section">
    <view>第2段案例:flex-direction : row</view>
    <view style="display: flex;flex-direction:row">  <!--横着显示-->
        <view class="flex-item bc_green"></view>
        <view class="flex-item bc_red"></view>
        <view class="flex-item bc_blue"></view>
    </view>
  </view>
  <!--第3段的案例:竖着显示的代码演示-->
  <view class="page-section">
   <view>第3段的案例:flex-direction:column</view> 
    <view style="display: flex;flex-direction:column">  <!--竖着显示-->
      <view class="flex-item bc_green"></view>
      <view class="flex-item bc_red"></view>
      <view class="flex-item bc_blue"></view>
    </view>
  </view>


  <!--第4段案例:justify-content代码演示flex-start-->
  <view class="page-section">
  <view>第4段案例:justify-content:flex-start</view>
    <view style="display: flex; flex-direction: row;justify-content:flex-start;"><!--放在左边开始显示-->
      <view class="flex-item bc_green"></view>
      <view class="flex-item bc_red"></view>
      <view class="flex-item bc_blue"></view>
    </view>
  </view>
  
  <!--第5段案例:justify-content代码演示flex-end-->
  <view class="page-section">    
  <view>第5段案例:justify-content:flex-end</view>
    <view style="display: flex; flex-direction: row;justify-content:flex-end;"><!--放在右边开始显示-->
      <view class="flex-item bc_green"></view>
      <view class="flex-item bc_red"></view>
      <view class="flex-item bc_blue"></view>
    </view>
  </view>


  
  <!---第6段案例:justify-content代码演示center-->
  <view class="page-section">
  <view>第6段案例:justify-content:center</view>
    <view style="display: flex; flex-direction: row;justify-content:center;">
      <view class="flex-item bc_green"></view>
      <view class="flex-item bc_red"></view>
      <view class="flex-item bc_blue"></view>
    </view>
  </view>


  <!---第7段案例:justify-content代码演示space-between-->
  <view class="page-section">
  <view>第7段案例:justify-content:space-between</view>
    <view style="display:flex;flex-direction:row; justify-content:space-between;">
      <view class="flex-item bc_green"></view>
      <view class="flex-item bc_red"></view>
      <view class="flex-item bc_blue"></view>
    </view>
  </view>
  
  <!---第8段案例:justify-content代码演示space-around-->
  <view class="page-section">
  <view>第8段案例:justify-content:space-around</view>
    <view style="display:flex;flex-direction:row; justify-content:space-around;">
      <view class="flex-item bc_green"></view>
      <view class="flex-item bc_red"></view>
      <view class="flex-item bc_blue"></view>
  </view>


  <!---第9段案例:justify-content代码演示align-items:flex-start-->
  <view class="page-section">
  <view>第9段案例:align-items:flex-start</view>
    <view style="display:flex;height:200px;flex-direction:row;justify-content:space-around;align-items:flex-start">
      <view class="flex-item bc_green"></view>
      <view class="flex-item bc_red"></view>
      <view class="flex-item bc_blue"></view>
    </view>
  </view>


  <!---第10段案例:justify-content代码演示align-items:flex-end-->
  <view class="page-section">
  <view>第10段案例:align-items:flex-end</view>
    <view style="display:flex;height:200px;flex-direction:row;justify-content:space-around;align-items:flex-end">
      <view class="flex-item bc_green"></view>
      <view class="flex-item bc_red"></view>
      <view class="flex-item bc_blue"></view>
    </view>
  </view>


  <!---第11段案例:justify-content代码演示align-items:flex-center-->
  <view class="page-section">
  <view>第11段案例:align-items:flex-center</view>
    <view style="display:flex;height:200px;flex-direction:row;justify-content:space-around;align-items:flex-center">
      <view class="flex-item bc_green"></view>
      <view class="flex-item bc_red"></view>
      <view class="flex-item bc_blue"></view>
    </view>
  </view>
<!--结束-->
</view>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值