新聞中心
細說下微信小程序的wxss樣式文件。源碼:https://github.com/limingios/wxProgram.git 中的No.2
創(chuàng)新互聯(lián)公司專注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務,包含不限于成都做網(wǎng)站、成都網(wǎng)站設計、望江網(wǎng)絡推廣、小程序設計、望江網(wǎng)絡營銷、望江企業(yè)策劃、望江品牌公關、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運營等,從售前售中售后,我們都將竭誠為您服務,您的肯定,是我們最大的嘉獎;創(chuàng)新互聯(lián)公司為所有大學生創(chuàng)業(yè)者提供望江建站搭建服務,24小時服務熱線:13518219792,官方網(wǎng)址:www.cdcxhl.com
樣式rpx
原來在html里面都是使用px和pt,微信這邊自定義的rpx的方式。
文檔:https://developers.weixin.qq.com/miniprogram/dev/framework/view/wxss.html
/*?pages/index/index.wxss?*/ .txt-test{ ??margin-top:?800rpx; }
外部樣式引入
新建一個跟現(xiàn)有的文件夾內(nèi)的wxss名稱不一樣的,一個文件名稱,然后import 引入外部的wxss,就可以在wxml使用了。通過@import 的方式引入到本身要引入的wxss里面,然后
/*?pages/index/out.wxss?*/ .txt-left{ ??margin-left:?100rpx; }
/*?pages/index/index.wxss?*/ @import?"out.wxss"; .txt-test{ ??margin-top:?800rpx; }
//index.js Page({ ??data:?{ ????motto:?'測試下數(shù)據(jù)綁定', ????testoutcss:?'測試外部css樣式', ????userInfo:?{}, ????hasUserInfo:?false, ????canIUse:?wx.canIUse('button.open-type.getUserInfo') ??} })
?? {{motto}} ??{{testoutcss}}
樣式關鍵字使用數(shù)據(jù)綁定的方式
樣式里面也可以通過數(shù)據(jù)綁定的方式進行顯示
//index.js Page({ ??data:?{ ????motto:?'測試下數(shù)據(jù)綁定', ????testoutcss:?'測試外部css樣式', ????color:"red", ????userInfo:?{}, ????hasUserInfo:?false, ????canIUse:?wx.canIUse('button.open-type.getUserInfo') ??} })
color綁定的方式
?? {{motto}} ??? ??{{motto}} ??{{testoutcss}}
全局樣式和局部樣式名稱相同的選擇
全局樣式和局部樣式名稱相同時,按照局部的樣式進行
定義全局txt-right進行演示
/**app.wxss**/ .container?{ ??height:?100%; ??display:?flex; ??flex-direction:?column; ??align-items:?center; ??justify-content:?space-between; ??padding:?200rpx?0; ??box-sizing:?border-box; }? #txt-right{ ??margin-right:?100rpx; ??color:?yellow; }
定義局部txt-right進行演示
/*?pages/index/index.wxss?*/ @import?"out.wxss"; .txt-test{ ??margin-top:?800rpx; } #txt-right{ ??margin-right:?300rpx; ??color:?black; }
?? {{globalcss}} ? ??{{motto}} ??? ??{{motto}} ??{{testoutcss}}
PS:樣式這塊比較依賴html中的css,明白如何引用,關聯(lián)關系,style的方式自定義樣式。
>>原創(chuàng)文章,歡迎轉(zhuǎn)載。轉(zhuǎn)載請注明:轉(zhuǎn)載自IT人故事會,謝謝!
>>原文鏈接地址:「小程序JAVA實戰(zhàn)」 小程序wxss樣式文件的使用(七)
文章名稱:「小程序JAVA實戰(zhàn)」小程序wxss樣式文件的使用(七)
網(wǎng)址分享:http://fisionsoft.com.cn/article/jogcdh.html