common.scss 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. // 超出行数,自动显示行尾省略号,最多5行
  2. // 来自uView的温馨提示:当您在控制台看到此报错,说明需要在App.vue的style标签加上【lang="scss"】
  3. .u-relative,
  4. .u-rela {
  5. position: relative;
  6. }
  7. .u-absolute,
  8. .u-abso {
  9. position: absolute;
  10. }
  11. .u-font-xs {
  12. font-size: 22rpx;
  13. }
  14. .u-font-sm {
  15. font-size: 26rpx;
  16. }
  17. .u-font-md {
  18. font-size: 28rpx;
  19. }
  20. .u-font-lg {
  21. font-size: 30rpx;
  22. }
  23. .u-font-xl {
  24. font-size: 34rpx;
  25. }
  26. .u-col-center {
  27. align-items: center;
  28. }
  29. .u-col-top {
  30. align-items: flex-start;
  31. }
  32. .u-col-bottom {
  33. align-items: flex-end;
  34. }
  35. .u-row-center {
  36. justify-content: center;
  37. }
  38. .u-row-left {
  39. justify-content: flex-start;
  40. }
  41. .u-row-right {
  42. justify-content: flex-end;
  43. }
  44. .u-row-between {
  45. justify-content: space-between;
  46. }
  47. .u-row-around {
  48. justify-content: space-around;
  49. }
  50. .u-text-left {
  51. text-align: left;
  52. }
  53. .u-text-center {
  54. text-align: center;
  55. }
  56. .u-text-right {
  57. text-align: right;
  58. }
  59. .u-flex-col {
  60. /* #ifndef APP-NVUE */
  61. display: flex;
  62. /* #endif */
  63. flex-direction: column;
  64. }
  65. // 定义flex等分
  66. @for $i from 0 through 12 {
  67. .u-flex-#{$i} {
  68. flex: $i;
  69. }
  70. }
  71. // 定义字体(px)单位,小于20都为px单位字体
  72. @for $i from 9 to 20 {
  73. .u-font-#{$i} {
  74. font-size: $i + px;
  75. }
  76. }
  77. // 定义字体(rpx)单位,大于或等于20的都为rpx单位字体
  78. @for $i from 20 through 40 {
  79. .u-font-#{$i} {
  80. font-size: $i + rpx;
  81. }
  82. }
  83. // 定义内外边距,历遍1-80
  84. @for $i from 0 through 80 {
  85. // 只要双数和能被5除尽的数
  86. @if $i % 2 == 0 or $i % 5 == 0 {
  87. // 得出:u-margin-30或者u-m-30
  88. .u-margin-#{$i}, .u-m-#{$i} {
  89. margin: $i + rpx!important;
  90. }
  91. // 得出:u-padding-30或者u-p-30
  92. .u-padding-#{$i}, .u-p-#{$i} {
  93. padding: $i + rpx!important;
  94. }
  95. @each $short, $long in l left, t top, r right, b bottom {
  96. // 缩写版,结果如: u-m-l-30
  97. // 定义外边距
  98. .u-m-#{$short}-#{$i} {
  99. margin-#{$long}: $i + rpx!important;
  100. }
  101. // 定义内边距
  102. .u-p-#{$short}-#{$i} {
  103. padding-#{$long}: $i + rpx!important;
  104. }
  105. // 完整版,结果如:u-margin-left-30
  106. // 定义外边距
  107. .u-margin-#{$long}-#{$i} {
  108. margin-#{$long}: $i + rpx!important;
  109. }
  110. // 定义内边距
  111. .u-padding-#{$long}-#{$i} {
  112. padding-#{$long}: $i + rpx!important;
  113. }
  114. }
  115. }
  116. }
  117. // 重置nvue的默认关于flex的样式
  118. .u-reset-nvue {
  119. flex-direction: row;
  120. align-items: center;
  121. }
  122. @for $i from 1 through 5 {
  123. .u-line-#{$i} {
  124. /* #ifdef APP-NVUE */
  125. // nvue下,可以直接使用lines属性,这是weex特有样式
  126. lines: $i;
  127. text-overflow: ellipsis;
  128. overflow: hidden;
  129. flex: 1;
  130. /* #endif */
  131. /* #ifndef APP-NVUE */
  132. // vue下,单行和多行显示省略号需要单独处理
  133. @if $i == '1' {
  134. overflow: hidden;
  135. white-space: nowrap;
  136. text-overflow: ellipsis;
  137. } @else {
  138. display: -webkit-box!important;
  139. overflow: hidden;
  140. text-overflow: ellipsis;
  141. word-break: break-all;
  142. -webkit-line-clamp: $i;
  143. -webkit-box-orient: vertical!important;
  144. }
  145. /* #endif */
  146. }
  147. }
  148. // 此处加上!important并非随意乱用,而是因为目前*.nvue页面编译到H5时,
  149. // App.vue的样式会被uni-app的view元素的自带border属性覆盖,导致无效
  150. // 综上,这是uni-app的缺陷导致我们为了多端兼容,而必须要加上!important
  151. // 移动端兼容性较好,直接使用0.5px去实现细边框,不使用伪元素形式实现
  152. .u-border {
  153. border-width: 0.5px!important;
  154. border-color: $u-border-color!important;
  155. border-style: solid;
  156. }
  157. .u-border-top {
  158. border-top-width: 0.5px!important;
  159. border-color: $u-border-color!important;
  160. border-top-style: solid;
  161. }
  162. .u-border-left {
  163. border-left-width: 0.5px!important;
  164. border-color: $u-border-color!important;
  165. border-left-style: solid;
  166. }
  167. .u-border-right {
  168. border-right-width: 0.5px!important;
  169. border-color: $u-border-color!important;
  170. border-right-style: solid;
  171. }
  172. .u-border-bottom {
  173. border-bottom-width: 0.5px!important;
  174. border-color: $u-border-color!important;
  175. border-bottom-style: solid;
  176. }
  177. .u-border-top-bottom {
  178. border-top-width: 0.5px!important;
  179. border-bottom-width: 0.5px!important;
  180. border-color: $u-border-color!important;
  181. border-top-style: solid;
  182. border-bottom-style: solid;
  183. }
  184. // 去除button的所有默认样式,让其表现跟普通的view、text元素一样
  185. .u-reset-button {
  186. padding: 0;
  187. background-color: transparent;
  188. /* #ifndef APP-PLUS */
  189. font-size: inherit;
  190. line-height: inherit;
  191. color: inherit;
  192. /* #endif */
  193. /* #ifdef APP-NVUE */
  194. border-width: 0;
  195. /* #endif */
  196. }
  197. /* #ifndef APP-NVUE */
  198. .u-reset-button::after {
  199. border: none;
  200. }
  201. /* #endif */
  202. .u-hover-class {
  203. opacity: 0.7;
  204. }