Blame view

src/views/GrowUp/c_ImgBox.vue 3.39 KB
c0087cf1   夏洋涛   feat:创建项目
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<template>
  <div class="c_img_box" :class="'imgLen'+imgArr.length">
    <div class="img_item" v-for="(item,index) in imgArr" :key="index" :style="'background-image:url('+item+')'" @click.stop="handlePhoto(index)">
    </div>
  </div>
</template>
<script>
export default {
  props: ['imgArr','itemIndex'],
  methods:{
    handlePhoto(index){
      this.$emit('handlePhoto',this.itemIndex,index)
    }
  }
}
</script>
<style lang="scss">
.c_img_box {
  margin-top: 30px;
  .img_item {
    position: relative;
    overflow: hidden;
    display: inline-block;
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center;
  }
  &.imgLen1 {
    .img_item {
      margin: 0 auto;
      width: 700px;
      height: 700px;
    }
  }
  &.imgLen2 {
    display: flex;
    justify-content: space-between;
    .img_item {
      width: 346px;
      height: 346px;
    }
  }
  &.imgLen3 {
    .img_item {
      width: 228px;
      height: 228px;
      &:first-of-type {
        width: 464px;
        height: 464px;
        float: left;
        margin-right: 10px;
      }
      &:nth-of-type(2) {
        margin-bottom: 8px;
      }
    }
  }
  &.imgLen4 {
    .img_item {
      width: 228px;
      height: 228px;
      &:first-of-type {
        width: 100%;
        height: 346px;
        margin-bottom: 8px;
      }
      &:nth-of-type(2),
      &:nth-of-type(3) {
        margin-right: 9px;
      }
    }
  }
  &.imgLen5 {
    .img_item {
      width: 228px;
      height: 228px;
      &:nth-of-type(1) {
        margin-right: 10px;
      }
      &:nth-of-type(1),
      &:nth-of-type(2) {
        width: 346px;
        height: 346px;
        margin-bottom: 8px;
      }
      &:nth-of-type(3),
      &:nth-of-type(4) {
        margin-right: 9px;
      }
    }
  }
  &.imgLen6 {
    .img_item {
      width: 228px;
      height: 228px;
      &:first-of-type {
        width: 464px;
        height: 464px;
        float: left;
        margin-right: 10px;
        margin-bottom: 8px;
      }
      &:nth-of-type(2),
      &:nth-of-type(3) {
        margin-bottom: 8px;
      }
      &:nth-of-type(4),
      &:nth-of-type(5) {
        margin-right: 9px;
      }
    }
  }
  &.imgLen7 {
    .img_item {
      width: 228px;
      height: 228px;
      &:first-of-type {
        width: 100%;
        height: 346px;
        margin-bottom: 8px;
      }
      &:nth-of-type(2),
      &:nth-of-type(3),
      &:nth-of-type(4) {
        margin-bottom: 8px;
      }
      &:nth-of-type(2),
      &:nth-of-type(3),
      &:nth-of-type(5),
      &:nth-of-type(6) {
        margin-right: 9px;
      }
    }
  }
  &.imgLen8 {
    .img_item {
      width: 228px;
      height: 228px;
      &:nth-of-type(1) {
        margin-right: 10px;
      }
      &:nth-of-type(1),
      &:nth-of-type(2) {
        width: 346px;
        height: 346px;
        margin-bottom: 8px;
      }
      &:nth-of-type(3),
      &:nth-of-type(4),
      &:nth-of-type(5) {
        margin-bottom: 8px;
      }
      &:nth-of-type(3),
      &:nth-of-type(4),
      &:nth-of-type(6),
      &:nth-of-type(7) {
        margin-right: 9px;
      }
    }
  }
  &.imgLen9 {
    .img_item {
      width: 228px;
      height: 228px;
      &:not(:nth-of-type(3n)) {
        margin-right: 9px;
      }
      &:nth-of-type(1),
      &:nth-of-type(2),
      &:nth-of-type(3),
      &:nth-of-type(4),
      &:nth-of-type(5),
      &:nth-of-type(6) {
        margin-bottom: 8px;
      }
    }
  }
}
</style>