zoukankan      html  css  js  c++  java
  • 微信小程序实现自定义遮罩

    • 效果图:

    • 代码:

      1. wxml
             <!-- 触发遮罩前的视图-->
             <view>
               <button type="primary" bindtap="showCover">触发遮罩</button>
             </view>
             <!-- 遮罩层 -->
             <view wx:if="{{isShow}}" class='cover'>
               <!-- 可在此按需求自定义遮罩 -->
               <view class='cover_child'>
                 <text class="child-title">遮罩详情</text>
                 <block wx:for="{{dataList}}">
                   <view class="child-row">
                     <text>{{item.title}}</text>
                     <text>{{item.text}}</text>
                   </view>
                 </block>
               </view>
               <image catchtap="hideCover" class="cross" src="/images/cancel.png " />
               <view catchtap="hideCover" wx:if="{{isShow}}" class='bg'></view>
             </view>
    
    1. wxss
             .bg {
               position: fixed;
               top: 0;
               left: 0;
                100%;
               height: 100%;
               background: rgba(0, 0, 0, 0.5);
             }
             
             .cover {
                100%;
               height: 100%;
               position: fixed;
               top: 0;
               left: 0;
               display: flex;
               justify-content: center;
               align-items: center;
               z-index: 0;
             }
             
             .cover_child {
                600rpx;
               height: 830rpx;
               background: rgba(255, 255, 255, 1);
               border-radius: 20rpx;
               display: flex;
               flex-direction: column;
               z-index: 5;
             }
             
             .child-title {
               white-space: nowrap;
               margin-left: 43rpx;
               margin-top: 32rpx;
                137rpx;
               height: 32rpx;
               font-size: 34rpx;
               font-weight: bold;
               color: rgba(18, 90, 217, 1);
               line-height: 36rpx;
               margin-bottom: 31rpx;
             }
             
             .child-row {
               display: flex;
               flex-direction: row;
               margin-left: 41rpx;
               margin-top: 40rpx;
               height: 28rpx;
               font-size: 30rpx;
               font-weight: 500;
               color: rgba(3, 3, 3, 1);
               line-height: 36rpx;
             }
             
             .cross {
               margin-bottom: 110rpx;
               bottom: 0rpx;
               position: fixed;
                60rpx;
               height: 60rpx;
               z-index: 5;
             }
    
    1. javascript
             Page({
               data: {
                 isShow:false,
                 dataList:[
                   {
                     title:"文本类型:",
                     text:"文本内容"
                   },
                   {
                     title: "文本类型:",
                     text: "文本内容"
                   },
                   {
                     title: "文本类型:",
                     text: "文本内容"
                   },
                 ]
               },
               hideCover(){
                 this.setData({
                   isShow: false
                 })
               },
               showCover(){
                 this.setData({
                   isShow:true
                 })
               },
             })
    
  • 相关阅读:
    后缀自动机学习小记
    [bzoj4524] [loj#2047] [Cqoi2016] 伪光滑数
    [bzoj4825] [loj#2018] [Hnoi2017] 单旋
    [bzoj4571] [loj#2016] [Scoi2016] 美味
    [bzoj4569] [loj#2014] [Scoi2016] 萌萌哒
    [bzoj4568] [loj#2013] [Scoi2016] 幸运数字
    [bzoj4567] [loj#2012] [SCOI2016] 背单词
    deque双向队列
    STL_vector
    qsort与sort()
  • 原文地址:https://www.cnblogs.com/xunxian/p/12966678.html
Copyright © 2011-2022 走看看