微信小程序页面制作练习——制作一个九宫格导航图

要求:

代码实现:

先将所需要的资源图片存入我的image文件里面

模拟练习供参考,不建议这样存入image里,因为本地图片占内存太大,不能预览。

一、list.wxml里面搭建框架代码:

<!--pages/list/list.wxml-->
<navigation-bar title="Weixin" back="{{false}}" color="red"></navigation-bar>
<scroll-view class="scrollarea" scroll-y type="list">
<swiper interval="2000" autoplay="true" indicator-dots="true" indicator-color="black" indicator-active-color="gray">
    <swiper-item><image src="../../images/swiper01.jpg" mode="" style="width: 100%;height: 100%;"/></swiper-item>
    <swiper-item><image src="../../images/swiper02.jpg" mode=""  style="width: 100%;height: 100%;"/></swiper-item>
</swiper>
<view class="grids">
<view class="border">
    <image src="../../images/shi.png" mode="" style="width:80rpx;height:80rpx;"/>
    <text>美食</text>
</view>
<view class="border">
    <image src="../../images/xiu.png" mode="" style="width:80rpx;height:80rpx;"/>
    <text>装修</text>
</view>
<view class="border">
    <image src="../../images/yu.png" mode="" style="width:80rpx;height:80rpx;"/>
    <text>洗浴</text>
</view>
<view class="border">
    <image src="../../images/che.png" mode="" style="width:80rpx;height:80rpx;"/>
    <text>汽车</text>
</view>
<view class="border">
    <image src="../../images/chang.png" mode="" style="width:80rpx;height:80rpx;"/>
    <text>唱歌</text>
</view>
<view class="border">
    <image src="../../images/fang.png" mode="" style="width:80rpx;height:80rpx;"/>
    <text>住宿</text>
</view>
<view class="border">
    <image src="../../images/xue.png" mode="" style="width:80rpx;height:80rpx;"/>
    <text>学习</text>
</view>
<view class="border">
    <image src="../../images/gong.png" mode="" style="width:80rpx;height:80rpx;"/>
    <text>工作</text>
</view>
<view class="border">
    <image src="../../images/hun.png" mode="" style="width:80rpx;height:80rpx;"/>
    <text>结婚</text>
</view>
</view>
</scroll-view>

二、list.wxss搭建样式代码:

/* pages/list/list.wxss */
.grids{
    display: flex;
    flex-wrap: wrap;
    margin-left: 5rpx;
}
.border{
    display: flex;
    border: 1px solid rgb(167, 165, 165);
    width: 246rpx; /*750÷3 =250*/
    height: 250rpx;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}
.border text{
    font-size: smaller;
    color: gray;
    margin-top: 10rpx;
}
.border:nth-child(1){
    border: none;
}
.border:nth-child(2){
    border-right: none;
    border-bottom: none;
    border-top: none;
}
.border:nth-child(3){
    border-right: none;
    border-bottom: none;
    border-top: none;
}
.border:nth-child(4){
    border-right: none;
    border-bottom: none;
    border-left:none ;
}
.border:nth-child(5){
    border-right: none;
    border-bottom: none;
}
.border:nth-child(6){
    border-right: none;
    border-bottom: none;
}
.border:nth-child(7){
    border-right: none;
    border-left: none;
}
.border:nth-child(8){
    border-right: none;
}
.border:nth-child(9){
    border-right: none;
}

三、运行结果如图所示:

相关推荐

  1. 程序九宫布局,轮播

    2024-03-28 08:18:03       64 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-03-28 08:18:03       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-03-28 08:18:03       100 阅读
  3. 在Django里面运行非项目文件

    2024-03-28 08:18:03       82 阅读
  4. Python语言-面向对象

    2024-03-28 08:18:03       91 阅读

热门阅读

  1. 开发过程中PostgreSQL常用的SQL语句,持续更新ing

    2024-03-28 08:18:03       38 阅读
  2. 算法——深度优秀搜索和广度优秀搜索

    2024-03-28 08:18:03       42 阅读
  3. C++构造函数

    2024-03-28 08:18:03       32 阅读
  4. Laplace变换-2

    2024-03-28 08:18:03       38 阅读
  5. 基于Python的高考志愿辅助填报系统

    2024-03-28 08:18:03       41 阅读
  6. js文件同步和异步的引入问题

    2024-03-28 08:18:03       42 阅读
  7. http协议中缓存Cache-Control详解

    2024-03-28 08:18:03       38 阅读
  8. C#WPF控件Label宽度绑定到父控件的宽度

    2024-03-28 08:18:03       34 阅读