Skip to content

Commit 7849040

Browse files
committed
fix: wrap key in div to keep size in correct ratio
1 parent 8bfd533 commit 7849040

File tree

1 file changed

+32
-35
lines changed

1 file changed

+32
-35
lines changed

src/keyboard.vue

Lines changed: 32 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
// input(type="text", v-model="keyboardText", v-if="!input")
44
.keyboard
55
.line(v-for="(line, index) in keySet", :key="index")
6-
span(v-for="(key, index) in line", :key="index", :class="getClassesOfKey(key)", v-text="getCaptionOfKey(key)", @click="e => clickKey(e, key)", @mousedown="mousedown", :style="getKeyStyle(key)")
6+
div(v-for="(key, index) in line", :key="index", :class="getClassesOfKey(key)", :style="getKeyStyle(key)")
7+
div(v-if="!key.placeholder" v-text="getCaptionOfKey(key)", @click="e => clickKey(e, key)", @mousedown="mousedown")
78

89

910
</template>
@@ -308,72 +309,72 @@
308309
}
309310
310311
.key {
311-
&:not(:last-child) {
312-
margin-right: $margin;
313-
}
314-
315312
flex: $width;
316-
//width: $btnW;
317-
height: $height;
318-
line-height: $height;
319-
overflow: hidden;
320313
321-
vertical-align: middle;
322-
border: 1px solid #ccc;
323-
color: #333;
324-
background-color: #fff;
325-
box-shadow: 0px 2px 2px rgba(0, 0, 0, .6);
326-
border-radius: $radius;
314+
&.half {
315+
flex: $width / 2;
316+
}
317+
318+
> div {
319+
height: $height;
320+
line-height: $height;
321+
overflow: hidden;
327322
328-
font-size: 1.25em;
329-
text-align: center;
330-
white-space: nowrap;
331-
user-select: none;
332-
cursor: pointer;
323+
vertical-align: middle;
324+
border: 1px solid #ccc;
325+
color: #333;
326+
background-color: #fff;
327+
box-shadow: 0px 2px 2px rgba(0, 0, 0, .6);
328+
border-radius: $radius;
329+
330+
font-size: 1.25em;
331+
text-align: center;
332+
white-space: nowrap;
333+
user-select: none;
334+
cursor: pointer;
335+
}
333336
337+
&:not(:last-child) > div {
338+
margin-right: $margin;
339+
}
334340
335-
&.backspace {
341+
&.backspace > div {
336342
background-image: url("./icons/backspace.svg");
337343
background-position: center center;
338344
background-repeat: no-repeat;
339345
background-size: 35%;
340346
}
341-
342-
&.half {
343-
flex: $width / 2;
344-
}
345347
346-
&.control {
348+
&.control > div {
347349
color: #fff;
348350
background-color: #7d7d7d;
349351
border-color: #656565;
350352
}
351353
352-
&.featured {
354+
&.featured > div {
353355
color: #fff;
354356
background-color: #337ab7;
355357
border-color: #2e6da4;
356358
}
357359
358-
&:hover {
360+
&:hover > div {
359361
color: #333;
360362
background-color: #d6d6d6;
361363
border-color: #adadad;
362364
}
363365
364-
&:active {
366+
&:active > div {
365367
transform: scale(.98); // translateY(1px);
366368
color: #333;
367369
background-color: #d4d4d4;
368370
border-color: #8c8c8c;
369371
}
370372
371-
&.activated {
373+
&.activated > div {
372374
color: #fff;
373375
background-color: #5bc0de;
374376
border-color: #46b8da;
375377
}
376-
377378
} // .key
378379
/*
379380
// Apple style
@@ -417,10 +418,6 @@
417418
flex: $width / 2;
418419
height: $height;
419420
line-height: $height;
420-
421-
&:not(:last-child) {
422-
margin-right: $margin;
423-
}
424421
}
425422
426423

0 commit comments

Comments
 (0)