小程序中怎么使用text文本組件?下面本篇文章給大家介紹一下小程序中text文本組件的使用方法,希望對大家有所幫助!
在微信小程序中,組件 text 用來顯示文本,基本使用代碼如下:
1、基本樣式設(shè)置
基本使用還是比較簡單的,下面咱們來論述一下文本樣式的設(shè)置,首先是給他設(shè)置一個 class
<text class="text">測試使用</text>然后在對應(yīng)的 wxss 文件中編寫樣式,對于字體來說 常用的就是字體大小、顏色、粗細(xì)的配置
.text { /* 字體大小 */ font-size: 20px; /* 字體顏色 */ color: red; /* 字體風(fēng)格-粗細(xì) */ font-weight: bold;}font-weight:設(shè)置文本字體的粗細(xì)。取值范圍為100-900,取值:mormal:正常大小相當(dāng)于400。bold :粗體,相當(dāng)于700
2、邊框設(shè)置
border-width:設(shè)置邊框?qū)挾龋撼S萌≈担簃edium:默認(rèn)值,相當(dāng)于3px。thin:1px。thick:5px。不可以為負(fù)值。
border-color:設(shè)置邊框顏色。
border-top:設(shè)置頂部邊框。
border-top-width,border-top-style,border-top-color 分別設(shè)置 寬度,樣式以及顏色
border-right:設(shè)置右邊框。
border-bottom:設(shè)置底邊框。
border-left:設(shè)置左邊框
border-radius:設(shè)置對象使用圓角邊框。取值為數(shù)字或者百分比。
border-style(邊框樣式)常見樣式有: (border-color,border-width) 邊框相關(guān)設(shè)置dashed(虛線)| dotted(點線)| solid(實線)。
.text { /* 字體大小 */ font-size: 20px; /* 字體顏色 */ color: red; /* 字體風(fēng)格-粗細(xì) */ font-weight: bold; border-color: blue; border-width:3px; border-style: solid;}例如還可以設(shè)置一下邊框圓角以及內(nèi)外邊距
.text { /* 字體大小 */ font-size: 20px; /* 字體顏色 */ color: red; /* 字體風(fēng)格-粗細(xì) */ font-weight: bold; border-color: blue; border-width:3px; border-style: solid; /* 內(nèi)邊距 */ padding: 10px; /* 外邊距 */ margin: 10px ; /* 設(shè)置邊框圓角 從左向右 */ /* 左上角 右上角 右下角 左下角 */ border-radius: 2px 4px 10px 20px;}3、設(shè)置斜體
通過font-style來設(shè)置,取值:normal 正常的字體, italic 斜體字, oblique 傾斜的字體。
.text2{/*文字排版--斜體*/font-style:italic;}4、設(shè)置下劃線
/*下劃線*/text-decoration:underline; /*刪除線*/text-decoration:line-through;text-decoration:line-through;
5、長文本段落的排版
.text2 { /*段落排版--首字縮進(jìn)*/ text-indent: 2em; /*段落排版--行間距(行高)*/ line-height: 1.5em; /*段落排版--中文字間距*/ letter-spacing: 1px; /*字母間距*/ word-spacing: 4px; /*文字對齊 right 、left 、center */ text-align: left;}【相關(guān)學(xué)習(xí)推薦:小程序開發(fā)教程】
網(wǎng)頁題目:淺析小程序中text文本組件的使用方法
鏈接地址:http://chinadenli.net/article46/cjjceg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供外貿(mào)建站、網(wǎng)站內(nèi)鏈、關(guān)鍵詞優(yōu)化、域名注冊、網(wǎng)站設(shè)計、用戶體驗
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)