Skip to content

Commit 9cc9694

Browse files
committed
fix: wrap key in div to keep size in correct ratio
1 parent 8f37ccc commit 9cc9694

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>
@@ -316,72 +317,72 @@
316317
}
317318
318319
.key {
319-
&:not(:last-child) {
320-
margin-right: $margin;
321-
}
322-
323320
flex: $width;
324-
//width: $btnW;
325-
height: $height;
326-
line-height: $height;
327-
overflow: hidden;
328321
329-
vertical-align: middle;
330-
border: 1px solid #ccc;
331-
color: #333;
332-
background-color: #fff;
333-
box-shadow: 0px 2px 2px rgba(0, 0, 0, .6);
334-
border-radius: $radius;
322+
&.half {
323+
flex: $width / 2;
324+
}
325+
326+
> div {
327+
height: $height;
328+
line-height: $height;
329+
overflow: hidden;
335330
336-
font-size: 1.25em;
337-
text-align: center;
338-
white-space: nowrap;
339-
user-select: none;
340-
cursor: pointer;
331+
vertical-align: middle;
332+
border: 1px solid #ccc;
333+
color: #333;
334+
background-color: #fff;
335+
box-shadow: 0px 2px 2px rgba(0, 0, 0, .6);
336+
border-radius: $radius;
337+
338+
font-size: 1.25em;
339+
text-align: center;
340+
white-space: nowrap;
341+
user-select: none;
342+
cursor: pointer;
343+
}
341344
345+
&:not(:last-child) > div {
346+
margin-right: $margin;
347+
}
342348
343-
&.backspace {
349+
&.backspace > div {
344350
background-image: url("./icons/backspace.svg");
345351
background-position: center center;
346352
background-repeat: no-repeat;
347353
background-size: 35%;
348354
}
349-
350-
&.half {
351-
flex: $width / 2;
352-
}
353355
354-
&.control {
356+
&.control > div {
355357
color: #fff;
356358
background-color: #7d7d7d;
357359
border-color: #656565;
358360
}
359361
360-
&.featured {
362+
&.featured > div {
361363
color: #fff;
362364
background-color: #337ab7;
363365
border-color: #2e6da4;
364366
}
365367
366-
&:hover {
368+
&:hover > div {
367369
color: #333;
368370
background-color: #d6d6d6;
369371
border-color: #adadad;
370372
}
371373
372-
&:active {
374+
&:active > div {
373375
transform: scale(.98); // translateY(1px);
374376
color: #333;
375377
background-color: #d4d4d4;
376378
border-color: #8c8c8c;
377379
}
378380
379-
&.activated {
381+
&.activated > div {
380382
color: #fff;
381383
background-color: #5bc0de;
382384
border-color: #46b8da;
383385
}
384-
385386
} // .key
386387
/*
387388
// Apple style
@@ -425,10 +426,6 @@
425426
flex: $width / 2;
426427
height: $height;
427428
line-height: $height;
428-
429-
&:not(:last-child) {
430-
margin-right: $margin;
431-
}
432429
}
433430
434431

0 commit comments

Comments
 (0)