common.scss 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. .u-relative,
  2. .u-rela {
  3. position: relative;
  4. }
  5. .u-absolute,
  6. .u-abso {
  7. position: absolute;
  8. }
  9. .u-font-xs {
  10. font-size: 22rpx;
  11. }
  12. .u-font-sm {
  13. font-size: 26rpx;
  14. }
  15. .u-font-md {
  16. font-size: 28rpx;
  17. }
  18. .u-font-lg {
  19. font-size: 30rpx;
  20. }
  21. .u-font-xl {
  22. font-size: 34rpx;
  23. }
  24. .u-flex {
  25. display: flex;
  26. flex-direction: row;
  27. align-items: center;
  28. }
  29. .u-flex-wrap {
  30. flex-wrap: wrap;
  31. }
  32. .u-flex-nowrap {
  33. flex-wrap: nowrap;
  34. }
  35. .u-col-center {
  36. align-items: center;
  37. }
  38. .u-col-top {
  39. align-items: flex-start;
  40. }
  41. .u-col-bottom {
  42. align-items: flex-end;
  43. }
  44. .u-row-center {
  45. justify-content: center;
  46. }
  47. .u-row-left {
  48. justify-content: flex-start;
  49. }
  50. .u-row-right {
  51. justify-content: flex-end;
  52. }
  53. .u-row-between {
  54. justify-content: space-between;
  55. }
  56. .u-row-around {
  57. justify-content: space-around;
  58. }
  59. .u-text-left {
  60. text-align: left;
  61. }
  62. .u-text-center {
  63. text-align: center;
  64. }
  65. .u-text-right {
  66. text-align: right;
  67. }
  68. .u-flex-col {
  69. display: flex;
  70. flex-direction: column;
  71. }
  72. // 定义flex等分
  73. @for $i from 1 through 12 {
  74. .u-flex-#{$i} {
  75. flex: $i;
  76. }
  77. }
  78. // 定义字体(px)单位,小于20都为px单位字体
  79. @for $i from 9 to 20 {
  80. .u-font-#{$i} {
  81. font-size: $i + px;
  82. }
  83. }
  84. // 定义字体(rpx)单位,大于或等于20的都为rpx单位字体
  85. @for $i from 20 through 40 {
  86. .u-font-#{$i} {
  87. font-size: $i + rpx;
  88. }
  89. }
  90. // 定义内外边距,历遍1-80
  91. @for $i from 0 through 80 {
  92. // 只要双数和能被5除尽的数
  93. @if $i % 2 == 0 or $i % 5 == 0 {
  94. // 得出:u-margin-30或者u-m-30
  95. .u-margin-#{$i}, .u-m-#{$i} {
  96. margin: $i + rpx!important;
  97. }
  98. // 得出:u-padding-30或者u-p-30
  99. .u-padding-#{$i}, .u-p-#{$i} {
  100. padding: $i + rpx!important;
  101. }
  102. @each $short, $long in l left, t top, r right, b bottom {
  103. // 缩写版,结果如: u-m-l-30
  104. // 定义外边距
  105. .u-m-#{$short}-#{$i} {
  106. margin-#{$long}: $i + rpx!important;
  107. }
  108. // 定义内边距
  109. .u-p-#{$short}-#{$i} {
  110. padding-#{$long}: $i + rpx!important;
  111. }
  112. // 完整版,结果如:u-margin-left-30
  113. // 定义外边距
  114. .u-margin-#{$long}-#{$i} {
  115. margin-#{$long}: $i + rpx!important;
  116. }
  117. // 定义内边距
  118. .u-padding-#{$long}-#{$i} {
  119. padding-#{$long}: $i + rpx!important;
  120. }
  121. }
  122. }
  123. }