微信小程序 flex實(shí)現(xiàn)導(dǎo)航實(shí)例詳解
微信小程序 flex實(shí)現(xiàn)導(dǎo)航實(shí)例詳解

實(shí)現(xiàn)示意:

1.鏈接頂部?jī)?nèi)邊距,留出圓形圖標(biāo)的位置。
2.偽元素:before繪制圓形。
3.圓形中添加圖標(biāo)。
4.左右外邊距控制間距,及促使在需要的地方換行。
wxml:
<view class="serviceMenu"> <navigator url="http://xwbline.com/">資本</navigator> …… </view>
wxss:
.serviceMenu{
display:flex; //使用flex布局
flex-wrap:wrap; //子元素?fù)Q行
justify-content:center; //子元素居中對(duì)齊
padding:30rpx 0; //留出上下邊距
}
.serviceMenu navigator{
position:relative; //為了絕對(duì)定位
padding-top:120rpx; //留出圓形圖標(biāo)的位置
flex-basis:140rpx; //設(shè)定基礎(chǔ)寬度
margin:15rpx; //觸發(fā)換行位置(小程序會(huì)自動(dòng)換算,不必考慮適配)
text-align:center;
font-size:24rpx;
}
//創(chuàng)建圖標(biāo)
.serviceMenu navigator:before{
content:"\20";
position:absolute;
top:0;
left:50%;
margin-left:-55rpx;
width:110rpx;
height:110rpx;
border-radius:50%;
background:#bbc1cd;
}
//設(shè)定不同圖標(biāo)。注意鏈接地址是絕對(duì)地址,因?yàn)樾〕绦虿恢С窒鄬?duì)地址的背景圖。只支持image相對(duì)地址。
.serviceMenu navigator:nth-child(1):before{
background:#fc6e51 url(http://xwbline.com/icon_service_big01.png) no-repeat center center;
}
.serviceMenu navigator:nth-child(2):before{
background:#48cfad url(http://xwbline.com/icon_service_big02.png) no-repeat center center;
}
………………
如果需要字?jǐn)?shù)限制的話:
text{
display:block;
overflow:hidden;
white-space:nowrap;
text-overflow:ellipsis;
}
感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!
相關(guān)文章
微信小程序 wx.uploadFile在安卓手機(jī)上面the same task is working問(wèn)題解決
這篇文章主要介紹了微信小程序 wx.uploadFile在安卓手機(jī)上面the same task is working問(wèn)題解決的相關(guān)資料,需要的朋友可以參考下2016-12-12
JavaScript?腳本實(shí)現(xiàn)復(fù)雜的查詢改寫示例
這篇文章主要為大家介紹了JavaScript?腳本實(shí)現(xiàn)復(fù)雜的查詢改寫示例,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-07-07
一文詳解webpack中l(wèi)oader與plugin的區(qū)別
這篇文章主要為大家介紹了一文詳解webpack中l(wèi)oader與plugin的區(qū)別詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-02-02
微信小程序?qū)崿F(xiàn)拖拽 image 觸摸事件監(jiān)聽(tīng)的實(shí)例
這篇文章主要介紹了微信小程序?qū)崿F(xiàn)拖拽 image 觸摸事件監(jiān)聽(tīng)的實(shí)例的相關(guān)資料,這里提供image觸摸并監(jiān)聽(tīng)的簡(jiǎn)單實(shí)例,需要的朋友可以參考下2017-08-08

