微信小程序自学笔记-----文本和字体样式设置

微信小程序自学笔记-----文本和字体样式设置

用于自己自学微信小程序知识点总结,新手小白一枚,请大佬勿喷

知识要点
· 各种字体样式属性命名及含义
· 利用style和class设置字体样式的方法
· 在index.wxss和app.wxss定义样式的方法
· 各种文本样式属性命名及其含义
· 设置文本样式的方法
案例描述
设计一个小程序,分别利用style和class属性设置字体样式,在index.wxss中定义样式类。所有的文字都包含在一个边框内,边框内上方有标题。文字,边框和标题样式利用class属性来设置,在app.wxss中定义样式类。利用class属性设置文本样式包括:文本颜色、字符缩进、对齐文本、装饰文本、对文本进行缩进等等。
实现效果
在这里插入图片描述

index.wxml文件代码 app.wxml.

<!--index.wxml-->
<view class="box">
  <view class="title">字体样式设置</view>
  <view class="textStyle01">
    文本的属性可以定义文本的外观。通过设置文本的属性,您可以改变文本的颜色、
    字符间距,对齐文本,装饰文本,对文本进行缩进等等。
  </view>
  ==============================
  <view class="textStyle02">
    I have a good friend, and her name is Li Hua. We have become friends for about two years. She is very kind. When I
   step into the classroom for the first time, she helps me to get familiar with the strange environment. The most
    important thing is that we share the same interest, so we have a lot in common. I cherish our friendship so much
  </view>
  ==============================
  <view style="font-family:sans-serif;font-size:30px;">
    <view>利用Style设置字体样式</view>
    <view>字体:sans-serif,30像素</view>
  </view>
  ==============================
  <view class="fontStyle">
    <view>利用Class设置字体样式:</view>
    <view>字体:Curseive。</view>
  </view>
</view>

index.wss文件代码 index.wxss.

/**index.wxss**/
.fontStyle{
  font-family: cursive;
  font-size: 25px;
  font-style: italic;
  font-weight: bold;
}
.textStyle01{
  color: blue;
  letter-spacing: 10px;
  text-align: left;
  text-indent: 50px;
  text-decoration: underline;
  text-decoration-color: chartreuse;
  line-height: 30px;
  white-space: normal;
}
.textStyle00{
  text-align: justify;
  word-spacing: 20px;
  text-transform: uppercase;
  white-space: pre-wrap;
}

app.wss文件代码 app.wxss.

/**app.wxss**/
.box{
  border: 1px solid silver;
  margin: 20rpx;
  padding: 20rpx;
}
.title{
  font-size: 25px;
  text-align: center;
  margin-bottom: 15px;
  color: red;
}

· view组件支持使用 style、class属性来设置组件的样式,静态的样式一般写到class中,动态的样式一般写到style中,这样能够提高渲染的速度
· class引用的样式类可以在index.wxss和app.wxss中定义。
在app.wxss中定义的样式属于全局样式类,可以在项目的任意文件中使用
在index.wxss中定义的样式类一般只在index.wxml中使用

各属性名和含义

在这里插入图片描述
在这里插入图片描述打卡微信小程序学习第一天!!!

  • 0
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值