3
0

flex.scss 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. // .u-flex {
  2. // @include vue-flex(row);
  3. // }
  4. // .u-flex-x {
  5. // @include vue-flex(row);
  6. // }
  7. // .u-flex-y {
  8. // @include vue-flex(column);
  9. // }
  10. // .u-flex-xy-center {
  11. // @include vue-flex(row);
  12. // justify-content: center;
  13. // align-items: center;
  14. // }
  15. // .u-flex-x-center {
  16. // @include vue-flex(row);
  17. // justify-content: center;
  18. // }
  19. // .u-flex-y-center {
  20. // @include vue-flex(column);
  21. // justify-content: center;
  22. // }
  23. // flex布局
  24. .u-flex,
  25. .u-flex-row,
  26. .u-flex-x,
  27. .up-flex,
  28. .up-flex-row,
  29. .up-flex-x {
  30. @include flex;
  31. }
  32. .u-flex-y,
  33. .u-flex-column,
  34. .up-flex-y,
  35. .up-flex-column {
  36. @include flex(column);
  37. }
  38. .u-flex-x-center,
  39. .up-flex-x-center {
  40. @include flex;
  41. justify-content: center;
  42. }
  43. .u-flex-xy-center,
  44. .up-flex-xy-center {
  45. @include flex;
  46. justify-content: center;
  47. align-items: center;
  48. }
  49. .u-flex-y-center,
  50. .up-flex-y-center {
  51. @include flex;
  52. align-items: center;
  53. }
  54. .u-flex-x-left,
  55. .up-flex-x-left {
  56. @include flex;
  57. }
  58. .u-flex-x-reverse,
  59. .u-flex-row-reverse,
  60. .up-flex-x-reverse,
  61. .up-flex-row-reverse {
  62. flex-direction: row-reverse;
  63. }
  64. .u-flex-y-reverse,
  65. .u-flex-column-reverse,
  66. .up-flex-y-reverse,
  67. .up-flex-column-reverse {
  68. flex-direction: column-reverse;
  69. }
  70. /* #ifndef APP-NVUE */
  71. // 此处为vue版本的简写,因为nvue不支持同时作用于两个类名的样式写法
  72. // nvue下只能写成class="u-flex-x u-flex-x-reverse的形式"
  73. .u-flex.u-flex-reverse,
  74. .u-flex-row.u-flex-reverse,
  75. .u-flex-x.u-flex-reverse,
  76. .up-flex.up-flex-reverse,
  77. .up-flex-row.up-flex-reverse,
  78. .up-flex-x.up-flex-reverse {
  79. flex-direction: row-reverse;
  80. }
  81. .u-flex-column.u-flex-reverse,
  82. .u-flex-y.u-flex-reverse,
  83. .up-flex-column.up-flex-reverse,
  84. .up-flex-y.up-flex-reverse {
  85. flex-direction: column-reverse;
  86. }
  87. // 自动伸缩
  88. .u-flex-fill,
  89. .u-flex-fillp {
  90. flex: 1 1 auto;
  91. }
  92. // 边界自动伸缩
  93. .u-margin-top-auto,
  94. .u-m-t-auto,
  95. .up-margin-top-auto,
  96. .up-m-t-auto {
  97. margin-top: auto !important;
  98. }
  99. .u-margin-right-auto,
  100. .u-m-r-auto,
  101. .up-margin-right-auto,
  102. .up-m-r-auto {
  103. margin-right: auto !important;
  104. }
  105. .u-margin-bottom-auto,
  106. .u-m-b-auto,
  107. .up-margin-bottom-auto,
  108. .up-m-b-auto {
  109. margin-bottom: auto !important;
  110. }
  111. .u-margin-left-auto,
  112. .u-m-l-auto,
  113. .up-margin-left-auto,
  114. .up-m-l-auto {
  115. margin-left: auto !important;
  116. }
  117. .u-margin-center-auto,
  118. .u-m-c-auto,
  119. .up-margin-center-auto,
  120. .up-m-c-auto {
  121. margin-left: auto !important;
  122. margin-right: auto !important;
  123. }
  124. .u-margin-middle-auto,
  125. .u-m-m-auto,
  126. .up-margin-middle-auto,
  127. .up-m-m-auto {
  128. margin-top: auto !important;
  129. margin-bottom: auto !important;
  130. }
  131. /* #endif */
  132. // 换行
  133. .u-flex-wrap,
  134. .up-flex-wrap {
  135. flex-wrap: wrap;
  136. }
  137. // 反向换行
  138. .u-flex-wrap-reverse,
  139. .up-flex-wrap-reverse {
  140. flex-wrap: wrap-reverse;
  141. }
  142. // 主轴起点对齐
  143. .u-flex-start,
  144. .up-flex-start {
  145. justify-content: flex-start;
  146. }
  147. // 主轴中间对齐
  148. .u-flex-center,
  149. .up-flex-center {
  150. justify-content: center;
  151. }
  152. // 主轴终点对齐
  153. .u-flex-end,
  154. .up-flex-end {
  155. justify-content: flex-end;
  156. }
  157. // 主轴等比间距
  158. .u-flex-between,
  159. .up-flex-between {
  160. justify-content: space-between;
  161. }
  162. // 主轴均分间距
  163. .u-flex-around,
  164. .up-flex-around {
  165. justify-content: space-around;
  166. }
  167. // 交叉轴起点对齐
  168. .u-flex-items-start,
  169. .up-flex-items-start {
  170. align-items: flex-start;
  171. }
  172. // 交叉轴中间对齐
  173. .u-flex-items-center,
  174. .up-flex-items-center {
  175. align-items: center;
  176. }
  177. // 交叉轴终点对齐
  178. .u-flex-items-end,
  179. .up-flex-items-end {
  180. align-items: flex-end;
  181. }
  182. // 交叉轴第一行文字基线对齐
  183. .u-flex-items-baseline,
  184. .up-flex-items-baseline {
  185. /* #ifndef APP-NVUE */
  186. align-items: baseline;
  187. /* #endif */
  188. }
  189. // 交叉轴方向拉伸对齐
  190. .u-flex-items-stretch,
  191. .up-flex-items-stretch {
  192. align-items: stretch;
  193. }
  194. // 以下属于项目(子元素)的类
  195. // 子元素交叉轴起点对齐
  196. /* #ifndef APP-NVUE */
  197. .u-flex-self-start,
  198. .up-flex-self-start {
  199. align-self: flex-start;
  200. }
  201. // 子元素交叉轴居中对齐
  202. .u-flex-self-center,
  203. .up-flex-self-center {
  204. align-self: center;
  205. }
  206. // 子元素交叉轴终点对齐
  207. .u-flex-self-end,
  208. .up-flex-self-end {
  209. align-self: flex-end;
  210. }
  211. // 子元素交叉轴第一行文字基线对齐
  212. .u-flex-self-baseline,
  213. .up-flex-self-baseline {
  214. align-self: baseline;
  215. }
  216. // 子元素交叉轴方向拉伸对齐
  217. .u-flex-self-stretch,
  218. .up-flex-self-stretch {
  219. align-self: stretch;
  220. }
  221. /* #endif */
  222. // 多轴交叉时的对齐方式
  223. // 起点对齐
  224. /* #ifndef APP-NVUE */
  225. .u-flex-content-start,
  226. .up-flex-content-start {
  227. align-content: flex-start;
  228. }
  229. // 居中对齐
  230. .u-flex-content-center,
  231. .up-flex-content-center {
  232. align-content: center;
  233. }
  234. // 终点对齐
  235. .u-flex-content-end,
  236. .up-flex-content-end {
  237. align-content: flex-end;
  238. }
  239. // 两端对齐
  240. .u-flex-content-between,
  241. .up-flex-content-between {
  242. align-content: space-between;
  243. }
  244. // 均分间距
  245. .u-flex-content-around,
  246. .up-flex-content-around {
  247. align-content: space-around;
  248. }
  249. // 全部居中对齐
  250. .u-flex-middle,
  251. .up-flex-middle {
  252. justify-content: center;
  253. align-items: center;
  254. align-self: center;
  255. align-content: center;
  256. }
  257. // 是否可以放大
  258. .u-flex-grow,
  259. .up-flex-grow {
  260. flex-grow: 1;
  261. }
  262. // 是否可以缩小
  263. .u-flex-shrink,
  264. .up-flex-shrink {
  265. flex-shrink: 1;
  266. }
  267. /* #endif */
  268. // 定义内外边距,历遍1-80
  269. @for $i from 0 through 80 {
  270. // 只要双数和能被5除尽的数
  271. @if $i % 2 == 0 or $i % 5 == 0 {
  272. // 得出:up-margin-30或者u-m-30
  273. .u-margin-#{$i}, .u-m-#{$i},
  274. .up-margin-#{$i}, .up-m-#{$i} {
  275. margin: $i + rpx!important;
  276. }
  277. // 得出:up-padding-30或者u-p-30
  278. .u-padding-#{$i}, .u-p-#{$i},
  279. .up-padding-#{$i}, .up-p-#{$i} {
  280. padding: $i + rpx!important;
  281. }
  282. @each $short, $long in l left, t top, r right, b bottom {
  283. // 缩写版,结果如: up-m-l-30
  284. // 定义外边距
  285. .u-m-#{$short}-#{$i},
  286. .up-m-#{$short}-#{$i} {
  287. margin-#{$long}: $i + rpx!important;
  288. }
  289. // 定义内边距
  290. .u-p-#{$short}-#{$i},
  291. .up-p-#{$short}-#{$i} {
  292. padding-#{$long}: $i + rpx!important;
  293. }
  294. // 完整版,结果如:up-margin-left-30
  295. // 定义外边距
  296. .u-margin-#{$long}-#{$i},
  297. .up-margin-#{$long}-#{$i} {
  298. margin-#{$long}: $i + rpx!important;
  299. }
  300. // 定义内边距
  301. .u-padding-#{$long}-#{$i},
  302. .up-padding-#{$long}-#{$i} {
  303. padding-#{$long}: $i + rpx!important;
  304. }
  305. }
  306. }
  307. }