時(shí)間:2023-07-24 02:24:02 | 來源:網(wǎng)站運(yùn)營
時(shí)間:2023-07-24 02:24:02 來源:網(wǎng)站運(yùn)營
手把手第五篇:簡單編寫小程序的 CSS 樣式:在上期文章中,我們主要聊了聊如何寫出一個(gè)簡單的小程序。既然聊到了編寫小程序,那不得不提的就是如何編寫其中的 CSS 樣式內(nèi)容,一起來看看吧。本期文章屬于《手把手系列教學(xué)》的第五篇,如果你還不太了解這一系列,可以點(diǎn)擊 這里 查看詳情。
由于 FinClip 小程序保持了與微信小程序的高度統(tǒng)一,來降低開發(fā)者的學(xué)習(xí)或遷移門檻,事實(shí)上你也可以直接在 FIDE 中編輯基于微信小程序的項(xiàng)目內(nèi)容,或者將基于微信小程序編輯的內(nèi)容進(jìn)行校驗(yàn)后,同步上傳在 FinClip 之中。
.container { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 200rpx 0; box-sizing: border-box;}
FIDE 初始化小程序頁面已經(jīng)給最外層標(biāo)簽添加了 container 類,此時(shí)在 container 類名下添加一個(gè) color 樣式:color: #ff0000;
保存后頁面重新渲染,文字變?yōu)榧t色:<view class="container unique-class">index頁</view>.unique-class{ font-size: 66px;}
此時(shí) page1 頁同樣添加class:“unique-class”,樣式并沒有受到影響<view class="container unique-class" style="color: {{fontColor}}"> index頁</view>
在頁面 data 中添加 fontColor 變量,賦值為想要的顏色Page({ data: { motto: 'Hello World', fontColor: '#10aeff' }})
同樣,插值變量的方式也可以運(yùn)用到 class 中以達(dá)到相似的效果。合理使用 rpx 會讓小程序體驗(yàn)感更好。
/** common.wxss **/.small-p { padding:5px;}/** app.wxss **/@import "common.wxss";.middle-p { padding:15px;}
<view> <swiper indicator-dots="{{true}}" autoplay="{{true}}" style="width: 750rpx; height: 750rpx; text-align: center;"> <swiper-item> <image src="/assets/images/logo.png"></image> </swiper-item> <swiper-item> <image src="/assets/images/logo2.png"></image> </swiper-item> <swiper-item> <image src="/assets/images/logo3.png"></image> </swiper-item> </swiper></view>
上面代碼中,<swiper> 組件就是輪播組件,里面放置了三個(gè) <swiper-item> 組件,表示有三個(gè)輪播項(xiàng)目,每個(gè)項(xiàng)目就是一個(gè) <image> 組件。關(guān)鍵詞:程序,樣式,編寫,簡單,把手
客戶&案例
營銷資訊
關(guān)于我們
微信公眾號
版權(quán)所有? 億企邦 1997-2025 保留一切法律許可權(quán)利。