質問編集履歴

2

補足の追加

2020/05/22 10:11

投稿

smilax630
smilax630

スコア34

test CHANGED
File without changes
test CHANGED
@@ -8,6 +8,10 @@
8
8
 
9
9
 
10
10
 
11
+ activeクラスがついてる間は、スクロールできないという状態を想定しています
12
+
13
+
14
+
11
15
  App.vue
12
16
 
13
17
  ```Vue

1

コードの追加

2020/05/22 10:11

投稿

smilax630
smilax630

スコア34

test CHANGED
File without changes
test CHANGED
@@ -5,3 +5,267 @@
5
5
 
6
6
 
7
7
  具体的にどんな施策が考えられるでしょうか
8
+
9
+
10
+
11
+ App.vue
12
+
13
+ ```Vue
14
+
15
+ <template>
16
+
17
+ <div id="app" :class="{ active: isActive }">
18
+
19
+ <Header @fixed="changeActive" ></Header>
20
+
21
+ <router-view/>
22
+
23
+ </div>
24
+
25
+ </template>
26
+
27
+
28
+
29
+ <script lang="ts">
30
+
31
+ import Vue from 'vue'
32
+
33
+ import Header from '@/components/Header.vue'
34
+
35
+ export type DataType = { isActive: boolean }
36
+
37
+ export default Vue.extend({
38
+
39
+ components: {
40
+
41
+ Header
42
+
43
+ },
44
+
45
+ data(): DataType{
46
+
47
+ return {
48
+
49
+ isActive: false
50
+
51
+ }
52
+
53
+ },
54
+
55
+ methods: {
56
+
57
+ changeActive() {
58
+
59
+ this.isActive = !this.isActive
60
+
61
+ },
62
+
63
+ }
64
+
65
+ })
66
+
67
+ </script>
68
+
69
+ <style>
70
+
71
+ body {
72
+
73
+ margin: 0;
74
+
75
+ }
76
+
77
+ .active {
78
+
79
+ position: fixed;
80
+
81
+ }
82
+
83
+ #app {
84
+
85
+ font-family: Avenir, Helvetica, Arial, sans-serif;
86
+
87
+ -webkit-font-smoothing: antialiased;
88
+
89
+ -moz-osx-font-smoothing: grayscale;
90
+
91
+ text-align: center;
92
+
93
+ color: #2c3e50;
94
+
95
+ }
96
+
97
+ </style>
98
+
99
+
100
+
101
+ ```
102
+
103
+
104
+
105
+
106
+
107
+ Header.vue
108
+
109
+ ```Vue
110
+
111
+ <template lang="pug">
112
+
113
+ .head
114
+
115
+ .header
116
+
117
+ NAV(:aa="clickHumb")
118
+
119
+ img.logo(src="../assets/hobo_logo.svg" alt="logo")
120
+
121
+ .humb(@click="openMenu")
122
+
123
+ .first-line
124
+
125
+ .last-line
126
+
127
+ </template>
128
+
129
+ <script lang="ts">
130
+
131
+ import Vue from 'vue'
132
+
133
+ import NAV from '@/components/Nav.vue'
134
+
135
+
136
+
137
+ export type DataType = { clickHumb: boolean }
138
+
139
+ export default Vue.extend({
140
+
141
+ data(): DataType {
142
+
143
+ return {
144
+
145
+ clickHumb: false
146
+
147
+ }
148
+
149
+ },
150
+
151
+ components: {
152
+
153
+ NAV
154
+
155
+ },
156
+
157
+
158
+
159
+ methods: {
160
+
161
+ openMenu() {
162
+
163
+ this.clickHumb = !this.clickHumb
164
+
165
+
166
+
167
+ if (this.clickHumb === true){
168
+
169
+ this.$emit('fixed')
170
+
171
+ }
172
+
173
+ }
174
+
175
+ }
176
+
177
+ })
178
+
179
+ </script>
180
+
181
+
182
+
183
+ <style scoped>
184
+
185
+ .head {
186
+
187
+ height: 60px;
188
+
189
+ }
190
+
191
+ .header{
192
+
193
+ position: relative;
194
+
195
+ width: 100%;
196
+
197
+ }
198
+
199
+ .header:hover > .logo{
200
+
201
+ opacity: 0.7;
202
+
203
+ }
204
+
205
+ .logo{
206
+
207
+ width: 150px;
208
+
209
+ margin-top: 5px;
210
+
211
+ margin-bottom: 5px;
212
+
213
+ transition: opacity 0.4s;
214
+
215
+ }
216
+
217
+ .humb{
218
+
219
+ width: 35px;
220
+
221
+ display: inline-block;
222
+
223
+ position: fixed;
224
+
225
+ top: 10px;
226
+
227
+ right: 10px;
228
+
229
+ padding-top: 20px;
230
+
231
+ padding-right: 20px;
232
+
233
+ padding-bottom: 10px;
234
+
235
+ }
236
+
237
+ .humb:hover > .first-line{
238
+
239
+ transform: translateY(3px);
240
+
241
+ }
242
+
243
+ .humb:hover > .last-line{
244
+
245
+ transform: translateY(7px);
246
+
247
+ }
248
+
249
+ .first-line {
250
+
251
+ border-bottom: 2px solid dimgray;
252
+
253
+ margin-bottom: 13px;
254
+
255
+ transition: all 0.5s;
256
+
257
+
258
+
259
+ }
260
+
261
+ .last-line {
262
+
263
+ border-top: 2px solid dimgray;
264
+
265
+ transition: all 0.5s;
266
+
267
+ }
268
+
269
+ </style>
270
+
271
+ ```