微信小程序--轮播图,标题,盒子,tab栏的合成例子
小程序是什么?
微信小程序,是一种不需要下载安装即可使用的应用,用户扫一扫或搜一下即可打开应用,在微信-发现-小程序可打开应用。
一.小程序的样式编写:

目录结构:

app.json
{
"pages": [
"pages/index/index",
"pages/message/message",
"pages/userCenter/userCenter",
"pages/contact/contact"
],
"window": {
"navigationBarBackgroundColor": "#13d1be",
"navigationBarTextStyle": "black",
"navigationBarTitleText":"本地宝",
"backgroundColor": "#eeeeee",
"backgroundTextStyle": "light",
"enablePullDownRefresh": false
},
"tabBar": {
"selectedColor":"rgb(238, 82, 61)",
"list": [{
"pagePath": "pages/index/index",
"text": "主页",
"iconPath": "tabs/home.png",
"selectedIconPath": "tabs/home-active.png"
},
{
"pagePath": "pages/message/message",
"text": "消息",
"iconPath": "tabs/message.png",
"selectedIconPath": "tabs/message-active.png"
},
{
"pagePath": "pages/userCenter/userCenter",
"text": "我的",
"iconPath": "tabs/profile.png",
"selectedIconPath": "tabs/profile-active.png"
},
{
"pagePath": "pages/contact/contact",
"text": "联系我们",
"iconPath": "tabs/contact.png",
"selectedIconPath": "tabs/contact-active.png"
}
]
}
}
公共样式:
/*公共的样式 */
/*伪元素边框-不占位置 */
.bd-r,.bd-t{
position: relative;
} .bd-r::after,.bd-t::before{
content: "";
position: absolute;
left:0;
top:0;
width: 100%;
height: 1rpx;
background-color: rgb(239, 239, 239);
} .bd-r::before{
right: 0;
left: auto;
width:1rpx;
height: 100%;
} .h100-block{
height: 10rpx;
background-color: #f0f0f0;
} /*利用flex伸缩盒属性,实现栅格化布局 */
.row{
display: flex;
} .row .col{
flex: 1;
}
主页页面编写:
index.wxml
<!--pages/index/index.wxml-->
<block>
<swiper indicator-dots="true" autoplay="true" interval="3000" duration="500" indicator-color='#f99' indicator-active-color='#f11' circular='true'>
<swiper-item>
<image src="../../images/banner-01.png" width="375" height="150" />
</swiper-item>
<swiper-item>
<image src="../../images/banner-02.png" width="375" height="150" />
</swiper-item> <swiper-item>
<image src="../../images/banner-01.png" width="375" height="150" />
</swiper-item>
<swiper-item>
<image src="../../images/banner-02.png" width="375" height="150" />
</swiper-item>
</swiper>
</block> <block>
<view class='index-nav'>
<navigator>
<view class='img bd-r bd-t'>
<image src='../../icons/grid-01.png'></image>
<text>美食</text>
</view>
</navigator> <navigator>
<view class='img bd-r bd-t'>
<image src='../../icons/grid-02.png'></image>
<text class='xizu'>洗浴足疗</text>
</view>
</navigator> <navigator>
<view class='img bd-r bd-t'>
<image src='../../icons/grid-03.png'></image>
<text class='jiehuntxt'>结婚啦</text>
</view>
</navigator> <navigator>
<view class='img bd-r bd-t'>
<image src='../../icons/grid-04.png'></image>
<text class='ktvtxt'>KTV</text>
</view>
</navigator> <navigator>
<view class='img bd-r bd-t'>
<image src='../../icons/grid-05.png'></image>
<text class='findworktext'>找工作</text>
</view>
</navigator> <navigator>
<view class='img bd-r bd-t'>
<image src='../../icons/grid-06.png'></image>
<text class='fudao'>辅导班</text>
</view>
</navigator> <navigator>
<view class='img bd-r bd-t'>
<image src='../../icons/grid-07.png'></image>
<text class='qichetext'>汽车保养</text>
</view>
</navigator> <navigator>
<view class='img bd-r bd-t'>
<image src='../../icons/grid-08.png'></image>
<text>租房</text>
</view>
</navigator> <navigator>
<view class='img bd-r bd-t'>
<image src='../../icons/grid-09.png'></image>
<text>装修</text>
</view>
</navigator>
</view>
</block>
<view class='h100-block'></view> <view class='index-enter row'> <view class='col'>
<navigator>
<image src='../../images/link-01.png'></image>
</navigator>
</view> <view class='col'>
<navigator>
<image src='../../images/link-02.png'></image>
</navigator>
</view>
</view>
主页样式:index.wxss
/* pages/index/index.wxss */
swiper-item image{
width: 750rpx;
height: 340rpx;
}
.index-nav{
overflow: hidden;
}
.img{
text-align: center;
font-size: 14px;
float: left;
width:33.3%;
height: 198rpx; /* box-sizing: border-box;
border-left: 1rpx solid rgb(239, 239, 239);
border-bottom: 1rpx solid rgb(239, 239, 239); */
}
/*选择第三个元素的倍数,把修饰用的边框隐藏 */
/*nth-of-type:选中类型的的第几个
::before需要配合content:''使用 */
.img:nth-of-type(3n)::before{
background-color: transparent;
} .img image{
width: 90rpx;
height: 90rpx;
display: block;
margin: 40rpx auto 20rpx;
} .img text{
display: block;
} .xizu{
left: 21%!important;
}
.jiehuntxt{
left: 29%!important;
} .findworktext{
left: 29%!important;
}
.fudao{
left: 29%!important;
}
.qichetext{
left: 21%!important;
} .index-enter image{
width: 320rpx;
height: 175rpx;
} .index-enter{
text-align: center;
padding: 10rpx ;
}
微信小程序--轮播图,标题,盒子,tab栏的合成例子的更多相关文章
- 图解微信小程序---轮播图
图解微信小程序---轮播图 代码笔记 第一步:在页面创建swiper组件 第二步:编写js页面 注意事项:wx:for渲染我们js中的图片数组,item默认写法,获取我们的图片数组中的图片,可通过增加 ...
- 微信小程序------轮播图
swiper 微信小程序实现轮播图,和网站,APP的效果差不多,代码少,效率高. 先来看看效果图: 主要用swiper + swiper-item来实现 <view class='swiper' ...
- 微信小程序——轮播图实现
小程序的轮播图,也就是他其中的一个控件可以算是直接上代码: 这是WXML 页面 代码: <view class='carousel_div'> <swiper class=" ...
- 微信小程序轮播图的制作与跳转
<!--轮播图 --> <view class='swiperBanner'> <swiper indicator-dots='{{indicatorDots}}' au ...
- 微信小程序轮播图组件 swiper,swiper-item及轮播图片自适应
官网地址:https://developers.weixin.qq.com/miniprogram/dev/component/swiper.html index.wxml文件 indicator-d ...
- 微信小程序轮播图
swiper标签 <!--index.wxml--> <swiper class="swiper" indicator-dots="true" ...
- 一分钟学会如何自定义小程序轮播图(蜜雪冰城Demo)
最近开发小程序项目用到了轮播图,默认的有点单调,作为后端程序员,研究一番最终实现了.本文会从思路,代码详细介绍,相信读过此文后,不管以后在开发中碰到轮播图还是需要自定义修改其他的样式都可以按这个思路解 ...
- 02微信小程序-轮播的宽度100%显示和轮播的基础配置
1==>如何让轮播的宽度100%显示? 你先给swiper 外面添加一个大盒子,给大盒子一个类 . <view class='lunbobox'> 然后wxss 里面设置 image ...
- 微信小程序轮播组件
在index.wxml中添加以下代码 <view> <swiper indicator-dots="{{indicatorDots}}" autoplay=&qu ...
随机推荐
- 基于SpringBoot免费开源的微信管家平台,Jeewx-Boot 1.0.3 版本发布
项目介绍 JeewxBoot 是一款基于SpringBoot的免费微信开发平台.支持微信公众号.小程序官网.微信抽奖活动.Jeewx-Boot实现了微信公众号管理.小程序CMS.微信抽奖活动等基础功能 ...
- java最大余数法(百分比算法Echarts)
最近工作中使用Echarts开发报表的时候遇到了这样的一个问题,需求是一个div中左边是一个环形图表,右边是一个表格,表格中展示图表中每个类别占用的百分比.存在的问题:1.当存在四舍五入的时候,Ech ...
- centos部署jeecms
首先下载安装包apache-tomcat-8.5.40.tar.gz jdk-8u211-linux-x641.rpm jeecmsv9.war 已经在WEB-INF/config/jdbc.prop ...
- 04_springmvc注解开发
一.注解开发 需求:1.进入商品查询列表页面. 2.点击修改,进入商品修改页面,页面中显示了要修改的商品(从数据库查询),要修改的商品从数据库查询,根据商品id(主键)查询商品信息. 3.在商品修改页 ...
- error C2440 “static_cast” 无法从“void (__thiscall C* )(void)...
1.VC6中,说可以把函数在头文件中定义为:afx_msg void OnProgress()这样 但是在VS2005及以上,要求很严格,必须函数返回值为LRESULT类型,所以在VS2005及以上, ...
- 阿里云 Aliplayer高级功能介绍(六):进度条标记
基本介绍 Aliplayer在进度条上提示时间和缩略图功能外,还可以进行视频内容的提示打点,当然不止是进度条上显示打点的内容,还提供一组接口,方便用户进行打点时间和内容的获取, 基本UI如下图所示: ...
- [转]iMPACT Spartan-6 FPGA - "WARNING:iMPACT:2217-Error shows in the status register, CRC Error bit is Not 0"
AR# 45304 iMPACT Spartan-6 FPGA - "WARNING:iMPACT:2217-Error shows in the status register, CRC ...
- linux学习(二)-----Linux 的目录结构、远程登录、vi和vim
linux目录结构 基本介绍 linux 的文件系统是采用级层式的树状目录结构,在此结构中的最上层是根目录“/”,然后在此 目录下再创建其他的目录. 目录结构具体介绍 Linux 目录总结 1.lin ...
- js 给链接 url或href或js、css、图片等解决浏览器缓存
一. 添加时间戳 情况一.链接是常量 var rand = new Date().getTime(); var aLen=document.getElementsByTagName("a&q ...
- postfix+自签证书,实现加密传输
说明:当前在centos 6.x环境下: cd /etc/pki/tls/misc ./CA -newca ..... 生成根证书 openssl req -new -nodes -keyout ma ...