初识微信小程序 文本样式设置

本文介绍了如何在微信小程序中使用class属性设置文本样式,包括文本颜色、字符间距、对齐方式、装饰、缩进等。示例代码展示了在wxss文件中定义不同样式的文本,并解释了各样式属性的作用,如`text-align`、`letter-spacing`、`text-indent`等。
摘要由CSDN通过智能技术生成

创建一个微信小程序,利用class属性设置文本样式,包括:文本的颜色、字符间距,对齐文本,装饰文本,对文本进行缩进,等等

<!--index.wxml-->
<view class="box">
  <view class='title'>文本样式设置</view>
  <view class='textStyle01'>
    文本属可以定义文本的外观。通过设置文本属性,可以
改变文本的颜色、字符间距,对齐文本,装饰文本,对文本
进行缩进,等等。
  </view>
  =====================
  <view class='textStyle02'>
    North China University of Technology (NCUT) 
is located in the western part of Beijing,which 
is a municipal
    University founded in 1946.
  </view>
</view>
/**index.wxss**/
.textStyle01{
  color:red;
  letter-spacing: 10px;
  text-align: left;
  text-indent: 50px;
  text-decoration: underline;
  text-decoration-color: #00f;
  line-height: 30px;
  white-space: normal;
}

.textStyle02{
  text-align: justify;
  word-spacing: 20px;
  text-transform: uppercase;
  white-space: pre-wrap;
}
/**app.wxss**/
.box{
  border:1px solid silver;
  margin: 20rpx;
  padding: 20rpx;
}

.title{
  font-size: 25px;
  text-align: center;
  margin-bottom: 15px;
  color: red;
}
属性名称含义
color字体颜色
text-align文本的对齐方式
text-indent首行缩进
letter-spacing字母之间的距离
word-sapcing单词间距,以空格来区分单词
white-sapce文档中的空白处
text-decoration文本修饰样式
text-decoration-color文本修饰颜色

设置文本样式的方法

  • 利用style和class属性进行设置。

  • 3
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值