index.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <template>
  2. <div class="waterfall-container">
  3. <el-card shadow="hover" header="瀑布屏(布局一)" class="mb15">
  4. <div class="waterfall-first">
  5. <div class="waterfall-first-item" v-for="v in 30" :key="v" v-waves>
  6. <div class="w100 h100 flex">
  7. <span class="flex-margin">{{ v }}</span>
  8. </div>
  9. </div>
  10. </div>
  11. </el-card>
  12. <el-card shadow="hover" header="瀑布屏(布局二)">
  13. <div class="waterfall-last">
  14. <div class="waterfall-last-item" v-for="v in 30" :key="v" v-waves="'light'">
  15. <div class="w100 h100 flex">
  16. <span class="flex-margin">{{ v }}</span>
  17. </div>
  18. </div>
  19. </div>
  20. </el-card>
  21. </div>
  22. </template>
  23. <script lang="ts">
  24. import { toRefs, reactive, defineComponent } from 'vue';
  25. export default defineComponent({
  26. name: 'pagesWaterfall',
  27. setup() {
  28. const state = reactive({});
  29. return {
  30. ...toRefs(state),
  31. };
  32. },
  33. });
  34. </script>
  35. <style scoped lang="scss">
  36. .waterfall-container {
  37. .waterfall-first {
  38. display: grid;
  39. grid-template-columns: repeat(auto-fill, minmax(188px, 1fr));
  40. grid-gap: 0.25em;
  41. grid-auto-flow: row dense;
  42. grid-auto-rows: 20px;
  43. .waterfall-first-item {
  44. width: 100%;
  45. background: var(--el-color-primary);
  46. color: var(--el-color-white);
  47. transition: all 0.3s ease;
  48. border-radius: 3px;
  49. &:nth-of-type(3n + 1) {
  50. grid-row: auto / span 5;
  51. }
  52. &:nth-of-type(3n + 2) {
  53. grid-row: auto / span 6;
  54. }
  55. &:nth-of-type(3n + 3) {
  56. grid-row: auto / span 8;
  57. }
  58. &:hover {
  59. box-shadow: 0 2px 12px 0 rgb(0 0 0 / 10%);
  60. transition: all 0.3s ease;
  61. cursor: pointer;
  62. }
  63. }
  64. }
  65. .waterfall-last {
  66. display: grid;
  67. grid-gap: 0.25em;
  68. grid-auto-flow: row dense;
  69. grid-auto-rows: minmax(188px, 20vmin);
  70. grid-template-columns: 1fr;
  71. .waterfall-last-item {
  72. height: 100%;
  73. background: var(--el-color-primary);
  74. color: var(--el-color-white);
  75. transition: all 0.3s ease;
  76. border-radius: 3px;
  77. &:hover {
  78. box-shadow: 0 2px 12px 0 rgb(0 0 0 / 10%);
  79. transition: all 0.3s ease;
  80. cursor: pointer;
  81. }
  82. }
  83. }
  84. @media (min-width: 576px) {
  85. .waterfall-last {
  86. grid-template-columns: repeat(7, 1fr);
  87. .waterfall-last-item {
  88. &:nth-of-type(9n + 9) {
  89. grid-column: auto / span 2;
  90. }
  91. &:nth-of-type(9n + 8) {
  92. grid-column: auto / span 2;
  93. }
  94. &:nth-of-type(9n + 7) {
  95. grid-column: auto / span 3;
  96. }
  97. &:nth-of-type(9n + 6) {
  98. grid-column: auto / span 2;
  99. }
  100. &:nth-of-type(9n + 5) {
  101. grid-column: auto / span 3;
  102. }
  103. &:nth-of-type(9n + 4) {
  104. grid-column: auto / span 2;
  105. }
  106. &:nth-of-type(9n + 3) {
  107. grid-column: auto / span 3;
  108. }
  109. &:nth-of-type(9n + 2) {
  110. grid-column: auto / span 2;
  111. }
  112. &:nth-of-type(9n + 1) {
  113. grid-column: auto / span 2;
  114. }
  115. }
  116. }
  117. }
  118. @media (min-width: 576px) and (min-width: 1024px) {
  119. .waterfall-last {
  120. grid-template-columns: repeat(14, 1fr);
  121. .waterfall-last-item {
  122. &:nth-of-type(15n + 15) {
  123. grid-column: auto / span 3;
  124. }
  125. &:nth-of-type(15n + 14) {
  126. grid-column: auto / span 3;
  127. }
  128. &:nth-of-type(15n + 13) {
  129. grid-column: auto / span 2;
  130. }
  131. &:nth-of-type(15n + 12) {
  132. grid-column: auto / span 3;
  133. }
  134. &:nth-of-type(15n + 11) {
  135. grid-column: auto / span 3;
  136. }
  137. &:nth-of-type(15n + 10) {
  138. grid-column: auto / span 2;
  139. }
  140. &:nth-of-type(15n + 9) {
  141. grid-column: auto / span 3;
  142. }
  143. &:nth-of-type(15n + 8) {
  144. grid-column: auto / span 3;
  145. }
  146. &:nth-of-type(15n + 7) {
  147. grid-column: auto / span 3;
  148. }
  149. &:nth-of-type(15n + 6) {
  150. grid-column: auto / span 3;
  151. }
  152. &:nth-of-type(15n + 5) {
  153. grid-column: auto / span 3;
  154. }
  155. &:nth-of-type(15n + 4) {
  156. grid-column: auto / span 3;
  157. }
  158. &:nth-of-type(15n + 3) {
  159. grid-column: auto / span 3;
  160. }
  161. &:nth-of-type(15n + 2) {
  162. grid-column: auto / span 3;
  163. }
  164. &:nth-of-type(15n + 1) {
  165. grid-column: auto / span 2;
  166. }
  167. }
  168. }
  169. }
  170. }
  171. </style>