UNPKG

chinese-keyboard.js

Version:

中文键盘:支持VUE2、VUE3、REACT、以及原生JS

185 lines (163 loc) 3.24 kB
/* 中文虚拟键盘样式 */ .chinese-keyboard { position: fixed; bottom: 0; left: 0; right: 0; background: #f8f9fa; border-top: 1px solid #e9ecef; box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1); z-index: 9999; max-width: 100vw; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; } /* 候选字区域 */ .candidate-area { background: #ffffff; border-bottom: 1px solid #e9ecef; padding: 8px; min-height: 40px; overflow-y: auto; } .pinyin-display { font-size: 30px; color: #007bff; margin-bottom: 8px; font-weight: 500; display: inline-block; } .candidates-container { display: flex; flex-wrap: wrap; margin-bottom: 8px; } .candidate-char { background: #ffffff; border: 1px solid #dee2e6; border-radius: 6px; padding: 8px 16px; margin-left: 4px; margin-right: 4px; font-size: 30px; color: #333; cursor: pointer; min-width: 44px; text-align: center; user-select: none; height: 70px; margin-bottom: 8px; } .no-hide { font-size: 30px !important; background: #6c757d; color: white; border: none; border-radius: 50%; width: 52px !important; height: 52px !important; cursor: pointer; display: flex; align-items: center; justify-content: center; } .candidate-char:active { background: #bbdefb; transform: translateY(0); } .pagination { display: flex; gap: 8px; justify-content: center; } .pagination button { background: #6c757d; color: white; border: none; border-radius: 50%; width: 32px; height: 32px; cursor: pointer; font-size: 30px; display: flex; align-items: center; justify-content: center; } /* 键盘主体 */ .keyboard-body { padding: 12px 6px; background: #f8f9fa; } .keyboard-row { display: flex; justify-content: center; margin-bottom: 8px; /* gap: 6px !important; */ } .keyboard-row:last-child { margin-bottom: 0; } /* 按键样式 */ .keyboard-key { margin-left: 3px; margin-right: 3px; flex: 1; background: linear-gradient(to bottom, #ffffff, #f8f9fa); border: 1px solid #dee2e6; border-radius: 8px; color: #333; font-size: 30px; font-weight: 500; cursor: pointer; user-select: none; height: 92px; width: 100px; touch-action: manipulation; min-height: 48px; display: flex; align-items: center; justify-content: center; position: relative; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); } /* 特殊按键样式 */ .keyboard-key--special { background: linear-gradient(to bottom, #007bff, #0056b3); color: white; border-color: #0056b3; font-weight: 600; } .keyboard-key--none { flex: 1 !important; } /* 空格键特殊样式 */ .keyboard-key--space { background: white; color: white; border-color: #0056b3; } /* 无障碍访问支持 */ .keyboard-key:focus { outline: 2px solid #007bff; outline-offset: 2px; } .candidate-char:focus { outline: 2px solid #007bff; outline-offset: 2px; } /* 防止文本选择 */ .chinese-keyboard * { -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; } .flex-1-2 { flex: 1.2 !important; } .flex-1-1 { flex: 1.1 !important; } .flex-4 { flex: 4 !important; }