复习微信小程序input组件和wxss样式写法。

Input组件

输入框组件(参考小程序文档)写的相当清楚。。

<view>
  <text>请输入第一个数字</text>
  <input type='number'value='点击此处输入数字'/>
</view>
<view>
  <text> 请输入第二个数字</text>
  <input type='number'/>
</view>
<button>比较</button>
<view>
  <text>比较结果</text>
</view>

属性value其实也不用必写。

属性type决定弹出手机键盘的样式。

为view组件设置样式

.wxss为设置样式的代码(参考简书小姐姐)非常详细

当热也可以直接在.wxml的view组件的type属性,只是不好套用。

margin(边缘):在组件四周增加空白。

选择器的使用

在/.wxss文件中样式的写法有几种

假如例如给view组件设置样式增加边缘

  • 1     element选择器
view {
  margin: 40rpx;
}

执行后view组件会增加边缘40rpx;

  • 2    .class选择器

在.wxss中写下(只多了一个点)

.view {
  margin: 40rpx;
}

然后在view组件的class属性声明。

<view class='view'>
<view>
  • 3      id选择器类似于.class选择器。

把.class的点换成#

#view {
  margin: 40rpx;
}

然后在view组件的id属性声明。

<view id='view'>
</view>

4      ::after选择器以及::befor选择器(参考这位)在组件后或前增加特别样式的文本。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个微信小程序详情页的示例代码,包含了 wxml 和 wxss: wxml: ```html <view class="container"> <!-- 商品图片轮播 --> <swiper class="swiper" indicator-dots="{{true}}" autoplay="{{true}}"> <swiper-item> <image src="/images/product1.png"></image> </swiper-item> <swiper-item> <image src="/images/product2.png"></image> </swiper-item> <swiper-item> <image src="/images/product3.png"></image> </swiper-item> </swiper> <!-- 商品信息 --> <view class="product-info"> <text class="name">商品名称</text> <text class="price">¥99</text> <text class="desc">这是一款非常好用的商品,非常适合您的需求,赶快购买吧!</text> </view> <!-- 商品规格 --> <view class="product-specification"> <text class="title">商品规格</text> <view class="specification-group"> <text class="label">颜色</text> <view class="specification"> <text class="value">黑色</text> <text class="value">白色</text> <text class="value">红色</text> </view> </view> <view class="specification-group"> <text class="label">尺码</text> <view class="specification"> <text class="value">S</text> <text class="value">M</text> <text class="value">L</text> </view> </view> </view> <!-- 商品详情 --> <view class="product-detail"> <text class="title">商品详情</text> <image class="detail-image" src="/images/detail.png"></image> </view> <!-- 底部操作栏 --> <view class="bottom-bar"> <view class="left"> <text class="iconfont icon-shoucang"></text> <text>收藏</text> </view> <view class="right"> <button class="add-cart">加入购物车</button> <button class="buy-now">立即购买</button> </view> </view> </view> ``` wxss: ```css .container { display: flex; flex-direction: column; align-items: center; padding: 20rpx; } .swiper { width: 100%; height: 400rpx; margin-bottom: 20rpx; } .product-info { width: 100%; margin-bottom: 20rpx; } .product-info .name { font-size: 32rpx; font-weight: bold; margin-bottom: 20rpx; } .product-info .price { font-size: 28rpx; color: #f44336; margin-bottom: 20rpx; } .product-info .desc { font-size: 28rpx; color: #666; line-height: 40rpx; } .product-specification { width: 100%; margin-bottom: 20rpx; } .product-specification .title { font-size: 28rpx; font-weight: bold; margin-bottom: 20rpx; } .specification-group { display: flex; flex-direction: column; margin-bottom: 20rpx; } .specification-group .label { font-size: 28rpx; font-weight: bold; margin-bottom: 10rpx; } .specification { display: flex; flex-wrap: wrap; } .specification .value { display: flex; justify-content: center; align-items: center; width: 100rpx; height: 60rpx; margin-right: 20rpx; margin-bottom: 20rpx; font-size: 26rpx; border: 1rpx solid #ddd; border-radius: 5rpx; } .product-detail { width: 100%; margin-bottom: 20rpx; } .product-detail .title { font-size: 28rpx; font-weight: bold; margin-bottom: 20rpx; } .product-detail .detail-image { width: 100%; } .bottom-bar { display: flex; justify-content: space-between; align-items: center; width: 100%; height: 100rpx; background-color: #fff; border-top: 1rpx solid #ddd; position: fixed; bottom: 0; left: 0; z-index: 999; } .bottom-bar .left { display: flex; align-items: center; margin-left: 20rpx; } .bottom-bar .left .iconfont { font-size: 36rpx; color: #666; margin-right: 10rpx; } .bottom-bar .left text { font-size: 28rpx; color: #666; } .bottom-bar .right { display: flex; align-items: center; margin-right: 20rpx; } .bottom-bar button { display: flex; justify-content: center; align-items: center; width: 200rpx; height: 80rpx; font-size: 28rpx; color: #fff; border-radius: 5rpx; margin-left: 10rpx; } .bottom-bar .add-cart { background-color: #f44336; } .bottom-bar .buy-now { background-color: #388e3c; } ``` 以上代码实现了一个简单的微信小程序详情页,包含了商品图片轮播、商品信息、商品规格、商品详情和底部操作栏。你可以根据自己的需求进行修改和优化。同时,建议添加一些交互和逻辑代码,实现加入购物车、立即购买等功能。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值