微信小程序代码片段: https://developers.weixin.qq.com/s/yNkjRYmF8f0R
开发钉钉小程序的时候,需要用到 Tabbar 类似公众号的样式组件,试着去写个简单的Demo,写完用微信小程序开发工具复用预览效果,发现可共用。
<view class="m-tab-bar">
<view class="tab-bar__item ">
<view class="tab-bar-item__content ">
首页
</view>
</view>
<view class="tab-bar__item ">
<view class="tab-bar-item__content ">
收藏
</view>
</view>
<view class="tab-bar__item ">
<view class="tab-bar-item__content tab-bar-item__content--checked">
喜欢
</view>
<view class="tab-bar-item__spread">
<view class="tab-bar-item__spread-item">
<view class="tab-bar-item__spread-item-text">基本信息</view>
</view>
<view class="tab-bar-item__spread-item">
<view class="tab-bar-item__spread-item-split"></view>
<view class="tab-bar-item__spread-item-text">个人主页</view>
</view>
<view class="tab-bar-item__spread-item">
<view class="tab-bar-item__spread-item-split"></view>
<view class="tab-bar-item__spread-item-text">设置</view>
</view>
</view>
</view>
</view>
.m-tab-bar {
position: relative;
width: 100%;
display: flex;
flex-wrap: nowrap;
align-items: center;
justify-content: center;
background-color: #fff;
}
.m-tab-bar .tab-bar__item {
height: 40px;
flex: 1;
padding: 0 12px;
margin: 8px 0;
position: relative;
}
.m-tab-bar .tab-bar__item .tab-bar-item__content {
text-align: center;
align-items: center;
justify-content: center;
display: flex;
background-color: #fff;
width: 100%;
height: 100%;
position: relative;
}
.m-tab-bar .tab-bar__item .tab-bar-item__spread {
position: absolute;
top: 0;
left: 7%;
width: 86%;
background-color: #ffffff;
-webkit-transform: translate3d(0, calc(-100% - 16px), 0);
transform: translate3d(0, calc(-100% - 16px), 0);
z-index: 1;
border-radius: 6px;
color: rgba(0, 0, 0, .9);
-webkit-box-shadow: 0 6px 30px 5px rgba(0, 0, 0, .05), 0 16px 24px 2px rgba(0, 0, 0, .04), 0 8px 10px -5px rgba(0, 0, 0, .08);
box-shadow: 0 6px 30px 5px rgba(0, 0, 0, .05), 0 16px 24px 2px rgba(0, 0, 0, .04), 0 8px 10px -5px rgba(0, 0, 0, .08);
}
.m-tab-bar .tab-bar__item .tab-bar-item__spread .tab-bar-item__spread-item {
width: 100%;
height: 48px;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-pack: start;
-ms-flex-pack: start;
justify-content: flex-start;
position: relative;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
}
.tab-bar-item__content--checked {
color: #3086ff;
font-weight: 600;
}
.m-tab-bar .tab-bar__item .tab-bar-item__spread .tab-bar-item__spread-item .tab-bar-item__spread-item-text {
padding-top: 12px;
}
.m-tab-bar .tab-bar__item .tab-bar-item__spread .tab-bar-item__spread-item .tab-bar-item__spread-item-split {
-webkit-box-sizing: border-box;
box-sizing: border-box;
content: " ";
pointer-events: none;
background-color: #e7e7e7;
width: 80%;
height: 1px;
-webkit-transform: translateY(.5);
transform: translateY(.5);
}
.tab-bar-item__spread:before {
display: block;
content: "";
position: absolute;
bottom: 0;
left: 50%;
width: 0;
height: 0;
border: 8px solid transparent;
border-top: 8px solid #fff;
-webkit-transform: translate3d(-50%, 16px, 0);
transform: translate3d(-50%, 16px, 0);
}
