目录
1. 小程序中组件的分类
2. 常用的视图容器类组件
view之横向排列
源代码
横向排列核心代码
scroll-view组件使用:上下滚动
3.轮播图swiper
效果
编写list.wxml文件
编写list.wxss文件
遇到的问题
1. 小程序中组件的分类
2. 常用的视图容器类组件
view之横向排列
今天讲的是view组件
目录结构
效果展示
源代码
编写list.wxml文件
<!--pages/list/list.wxml-->
<text>股好看pages/list/list.wxml</text>
<view class="container1">
<view>A</view>
<view>B</view>
<view>C</view>
</view>
编写list.wxss文件
/* pages/list/list.wxss */
.container1 view{
width: 100px;
height: 100px;
text-align: center;
line-height: 100px;
}
.container1 view:nth-child(1){
background-color: lightblue;
}
.container1 view:nth-child(2){
background-color: lightcoral;
}
.container1 view:nth-child(3){
background-color:lightgoldenrodyellow
}
.container1{
display: flex;
justify-content: space-around;
}
横向排列核心代码
.container1{
display: flex;
justify-content: space-around;
}
scroll-view组件使用:上下滚动
编写list.wxml文件
<!--pages/list/list.wxml-->
<text>股好看pages/list/list.wxml</text>
<scroll-view class="container1"scroll-y>
<view>A</view>
<view>B</view>
<view>C</view>
</scroll-view>
编写list.wxss文件
/* pages/list/list.wxss */
.container1 view{
width: 100px;
height: 100px;
text-align: center;
line-height: 100px;
}
.container1 view:nth-child(1){
background-color: lightblue;
}
.container1 view:nth-child(2){
background-color: lightcoral;
}
.container1 view:nth-child(3){
background-color:lightgoldenrodyellow
}
.container1{
border: 1px solid red;
height: 100px;
width: 100px;
}
3.轮播图swiper
效果
编写list.wxml文件
<swiper class="kk">
<!-- 第一个轮播图 -->
<swiper-item>
<view class="id">A</view>
</swiper-item>
<!-- 第二个轮播图 -->
<swiper-item>
<view class="id">B</view>
</swiper-item>
<!-- 第三个轮播图 -->
<swiper-item>
<view class="id">C</view>
</swiper-item>
</swiper>
编写list.wxss文件
/* pages/list/list.wxss */
.kk{
height: 150px;
}
.id{
/* 设置高度 */
height: 100%;
/* */
line-height: 150px;
/* s设置文本的位置 */
text-align: center;
}
/* 每个轮播图设置背景颜色
swiper-item:nth-child(1)后面要加上空格再+.id财会有颜色变化
*/
swiper-item:nth-child(1) .id{
background-color: aquamarine;
}
swiper-item:nth-child(2) .id{
background-color: rgb(255, 0, 55)
}
swiper-item:nth-child(3) .id{
background-color: aqua;
}
.container1 view{
width: 100px;
height: 100px;
text-align: center;
line-height: 100px;
}
.container1 view:nth-child(1){
background-color: lightblue;
}
.container1 view:nth-child(2){
background-color: lightcoral;
}
.container1 view:nth-child(3){
background-color:lightgoldenrodyellow
}
.container1{
border: 1px solid red;
height: 100px;
width: 100px;
}
遇到的问题
每个轮播图设置背景颜色 为什么没有颜色?文章来源:https://www.toymoban.com/news/detail-553365.html
swiper-item:nth-child(1)后面要加上空格再+.id财会有颜色变化文章来源地址https://www.toymoban.com/news/detail-553365.html
到了这里,关于小程序view基本组件使用的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!