at-rules.md 10.5 KB
Newer Older
D
DCloud_LXH 已提交
1 2 3 4
# At-rules

<!-- CSSJSON.at_rules_values.compatibility -->

DCloud-yyl's avatar
DCloud-yyl 已提交
5 6
## 字体  

D
DCloud_LXH 已提交
7 8 9 10 11 12 13 14
@font-face自定义字体示例:
```html
<style>
@font-face {
    font-family: AlimamaDaoLiTiOTF;
    src: url('/static/font/AlimamaDaoLiTi.otf');
}
</style>
D
DCloud_LXH 已提交
15 16
```

DCloud-yyl's avatar
DCloud-yyl 已提交
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
### 内置字体图标 uni-icon @uniicon  
> HBuilderX4.33版本开始 app-android、app-ios平台支持内置字体图标 uni-icon  

内置 `uni-icon` 字体图标示例:
```html
<template>
  <!-- #ifdef APP -->
  <scroll-view style="flex: 1;">
  <!-- #endif -->

  <text style="font-family: uni-icon;font-size: 64px;">{{uniIcon}}</text>

  <!-- #ifdef APP -->
  </scroll-view>
  <!-- #endif -->
</template>

<script lang="uts">
  export default {
    data() {
      return {
        uniIcon: '\ue605'
      }
    }
  }
</script>
```

内置 `uni-icon` 包括以下图标:  

<div class="iconSample">
  <div class="iconContainer">
    <div class="iconItem">
      <span class="icon">&#xE600</span>
      <span class="code">\uE600</span>
      <span class="name">forward</span>
    </div>
    <div class="iconItem">
      <span class="icon">&#xE601</span>
      <span class="code">\uE601</span>
      <span class="name">back</span>
    </div>
    <div class="iconItem">
      <span class="icon">&#xE602</span>
      <span class="code">\uE602</span>
      <span class="name">share</span>
    </div>
    <div class="iconItem">
      <span class="icon">&#xE604</span>
      <span class="code">\uE604</span>
      <span class="name">favorites</span>
    </div>
    <div class="iconItem">
      <span class="icon">&#xE605</span>
      <span class="code">\uE605</span>
      <span class="name">home</span>
    </div>
    <div class="iconItem">
      <span class="icon">&#xE606</span>
      <span class="code">\uE606</span>
      <span class="name">more</span>
    </div>
    <div class="iconItem">
      <span class="icon">&#xE650</span>
      <span class="code">\uE650</span>
      <span class="name">close</span>
    </div>
    <div class="iconItem">
      <span class="icon">&#xE661</span>
      <span class="code">\uE661</span>
      <span class="name">down</span>
    </div>
    <div class="iconItem">
      <span class="icon">&#xEA01</span>
      <span class="code">\uEA01</span>
      <span class="name">circle</span>
    </div>
    <div class="iconItem">
      <span class="icon">&#xEA03</span>
      <span class="code">\uEA03</span>
      <span class="name">info</span>
    </div>
    <div class="iconItem">
      <span class="icon">&#xEA04</span>
      <span class="code">\uEA04</span>
      <span class="name">info circle</span>
    </div>
    <div class="iconItem">
      <span class="icon">&#xEA06</span>
      <span class="code">\uEA06</span>
      <span class="name">success</span>
    </div>
    <div class="iconItem">
      <span class="icon">&#xEA07</span>
      <span class="code">\uEA07</span>
      <span class="name">success circle</span>
    </div>
    <div class="iconItem">
      <span class="icon">&#xEA08</span>
      <span class="code">\uEA08</span>
      <span class="name">success no circle</span>
    </div>
    <div class="iconItem">
      <span class="icon">&#xEA0B</span>
      <span class="code">\uEA0B</span>
      <span class="name">cancel circle</span>
    </div>
    <div class="iconItem">
      <span class="icon">&#xEA0F</span>
      <span class="code">\uEA0F</span>
      <span class="name">warn</span>
    </div>
    <div class="iconItem">
      <span class="icon">&#xEA14</span>
      <span class="code">\uEA14</span>
      <span class="name">clear</span>
    </div>
    <div class="iconItem">
      <span class="icon">&#xEA19</span>
      <span class="code">\uEA19</span>
      <span class="name">download</span>
    </div>
    <div class="iconItem">
      <span class="icon">&#xEA1E</span>
      <span class="code">\uEA1E</span>
      <span class="name">waiting</span>
    </div>
    <div class="iconItem">
      <span class="icon">&#xEA23</span>
      <span class="code">\uEA23</span>
      <span class="name">search</span>
    </div>
  </div>
</div>



D
DCloud_LXH 已提交
154 155
## Tips
- `字体路径`支持**网络****本地**,本地字体请注意放在项目或uni_modules的static目录下。
DCloud-yyl's avatar
DCloud-yyl 已提交
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200

<style type="text/css">
@font-face {
    font-family: 'uni-icon';
    src: url(data:font/ttf;charset=utf-8;base64,AAEAAAAKAIAAAwAgT1MvMhIACicAAACsAAAAYGNtYXBJB47VAAABDAAAAapnbHlm8llk8QAAArgAAAtEaGVhZCj1NF4AAA38AAAANmhoZWEHlQPxAAAONAAAACRobXR4DXMFkwAADlgAAAAybG9jYR7QHCgAAA6MAAAALm1heHABMgCPAAAOvAAAACBuYW1lne94ygAADtwAAAFlcG9zdHgRyWUAABBEAAAA7QAEA9oBkAAFAAACmQLMAAAAjwKZAswAAAHrADMBCQAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAAAAAAAAAAAAAAUAAIOojA8D/wABAA8AAQAAAAAEAAAAAAgACzQAAACAAAAAAAAMAAAADAAAAHAABAAAAAACkAAMAAQAAABwABACIAAAAHgAQAAMADgAg5gLmBuZQ5mHqAeoE6gjqC+oP6hTqGeoe6iP//wAAACDmAOYE5lDmYeoB6gPqBuoL6g/qFOoZ6h7qI////+EaAhoBGbgZqBYJFggWBxYFFgIV/hX6FfYV8gABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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AAAADgCuAAEAAAAAAAEACAAAAAEAAAAAAAIABgAIAAEAAAAAAAMACAAOAAEAAAAAAAQACAAWAAEAAAAAAAUABAAeAAEAAAAAAAYACAAiAAEAAAAAAAoAEwAqAAMAAQQJAAEAEAA9AAMAAQQJAAIADABNAAMAAQQJAAMAEABZAAMAAQQJAAQAEABpAAMAAQQJAAUACAB5AAMAAQQJAAYAEACBAAMAAQQJAAoAJgCRdW5pLWljb25NZWRpdW11bmktaWNvbnVuaS1pY29uMS4wIHVuaS1pY29udW5pLWFwcCB4IGljb24gZm9udAB1AG4AaQAtAGkAYwBvAG4ATQBlAGQAaQB1AG0AdQBuAGkALQBpAGMAbwBuAHUAbgBpAC0AaQBjAG8AbgAxAC4AMAAgAHUAbgBpAC0AaQBjAG8AbgB1AG4AaQAtAGEAcABwACAAeAAgAGkAYwBvAG4AIABmAG8AbgB0AAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABYAFgAAAAMBAgEDAQQBBQEGAQcBCAEJAQoBCwEMAQ0BDgEPARABEQESARMBFAEVB2ZvcndhcmQEYmFjawVzaGFyZQlmYXZvcml0ZXMEaG9tZQRtb3JlBWNsb3NlBGRvd24GY2lyY2xlBGluZm8KaW5mb2NpcmNsZQdzdWNjZXNzDXN1Y2Nlc3NjaXJjbGUPc3VjY2Vzc25vY2lyY2xlDGNhbmNlbGNpcmNsZQR3YXJuBWNsZWFyCGRvd25sb2FkB3dhaXRpbmcGc2VhcmNoAAAA) format('truetype');
}
.iconSample {
    background-color: #f8f8f8;
}
.iconContainer {
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: flex-start;
  display: flex;
}
.iconItem {
  width: 100px;
  height: 150px;
  align-items: center;
  align-content: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.icon {
  width: 48px;
  height: 48px;
  font-family: uni-icon;
  font-size: 42px;
  line-height: 48px;
  color: #333;
  margin-bottom: 8px;
  display: block;
}
.code {
  font-size: 14px;
  color: #f00;
  display: block;
}
.name {
  font-size: 12px;
  color: #000;
  display: block;
}
</style>