common.scss 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. .u-relative,
  2. .u-rela {
  3. position: relative;
  4. }
  5. .u-absolute,
  6. .u-abso {
  7. position: absolute;
  8. }
  9. page {
  10. background: $u-bg-color;
  11. }
  12. // nvue不能用标签命名样式,不能放在微信组件中,否则微信开发工具会报警告,无法使用标签名当做选择器
  13. /* #ifndef APP-NVUE */
  14. image {
  15. display: inline-block;
  16. }
  17. // 在weex,也即nvue中,所有元素默认为border-box
  18. view,
  19. text {
  20. box-sizing: border-box;
  21. }
  22. /* #endif */
  23. .u-font-xs {
  24. font-size: 22 rpx;
  25. }
  26. .u-font-sm {
  27. font-size: 26 rpx;
  28. }
  29. .u-font-md {
  30. font-size: 28 rpx;
  31. }
  32. .u-font-lg {
  33. font-size: 30 rpx;
  34. }
  35. .u-font-xl {
  36. font-size: 34 rpx;
  37. }
  38. .u-flex {
  39. /* #ifndef APP-NVUE */
  40. display: flex;
  41. /* #endif */
  42. flex-direction: row;
  43. align-items: center;
  44. }
  45. .u-flex-wrap {
  46. flex-wrap: wrap;
  47. }
  48. .u-flex-nowrap {
  49. flex-wrap: nowrap;
  50. }
  51. .u-col-center {
  52. align-items: center;
  53. }
  54. .u-col-top {
  55. align-items: flex-start;
  56. }
  57. .u-col-bottom {
  58. align-items: flex-end;
  59. }
  60. .u-row-center {
  61. justify-content: center;
  62. }
  63. .u-row-left {
  64. justify-content: flex-start;
  65. }
  66. .u-row-right {
  67. justify-content: flex-end;
  68. }
  69. .u-row-between {
  70. justify-content: space-between;
  71. }
  72. .u-row-around {
  73. justify-content: space-around;
  74. }
  75. .u-text-left {
  76. text-align: left;
  77. }
  78. .u-text-center {
  79. text-align: center;
  80. }
  81. .u-text-right {
  82. text-align: right;
  83. }
  84. .u-flex-col {
  85. /* #ifndef APP-NVUE */
  86. display: flex;
  87. /* #endif */
  88. flex-direction: column;
  89. }
  90. // 定义flex等分
  91. @for $i from 0 through 12 {
  92. .u-flex-#{$i} {
  93. flex: $i;
  94. }
  95. }
  96. // 定义字体(px)单位,小于20都为px单位字体
  97. @for $i from 9 to 20 {
  98. .u-font-#{$i} {
  99. font-size: $i + px;
  100. }
  101. }
  102. // 定义字体(rpx)单位,大于或等于20的都为rpx单位字体
  103. @for $i from 20 through 40 {
  104. .u-font-#{$i} {
  105. font-size: $i + rpx;
  106. }
  107. }
  108. // 定义内外边距,历遍1-80
  109. @for $i from 0 through 80 {
  110. // 只要双数和能被5除尽的数
  111. @if $i % 2 == 0 or $i % 5 == 0 {
  112. // 得出:u-margin-30或者u-m-30
  113. .u-margin-#{$i}, .u-m-#{$i} {
  114. margin: $i + rpx !important;
  115. }
  116. // 得出:u-padding-30或者u-p-30
  117. .u-padding-#{$i}, .u-p-#{$i} {
  118. padding: $i + rpx !important;
  119. }
  120. @each $short, $long in l left, t top, r right, b bottom {
  121. // 缩写版,结果如: u-m-l-30
  122. // 定义外边距
  123. .u-m-#{$short}-#{$i} {
  124. margin-#{$long}: $i + rpx !important;
  125. }
  126. // 定义内边距
  127. .u-p-#{$short}-#{$i} {
  128. padding-#{$long}: $i + rpx !important;
  129. }
  130. // 完整版,结果如:u-margin-left-30
  131. // 定义外边距
  132. .u-margin-#{$long}-#{$i} {
  133. margin-#{$long}: $i + rpx !important;
  134. }
  135. // 定义内边距
  136. .u-padding-#{$long}-#{$i} {
  137. padding-#{$long}: $i + rpx !important;
  138. }
  139. }
  140. }
  141. }
  142. // 重置nvue的默认关于flex的样式
  143. .u-reset-nvue {
  144. flex-direction: row;
  145. align-items: center;
  146. }