input.css 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. /*
  2. * noVNC general input element CSS
  3. * Copyright (C) 2022 The noVNC Authors
  4. * noVNC is licensed under the MPL 2.0 (see LICENSE.txt)
  5. * This file is licensed under the 2-Clause BSD license (see LICENSE.txt).
  6. */
  7. /*
  8. * Common for all inputs
  9. */
  10. input, input::file-selector-button, button, select, textarea {
  11. /* Respect standard font settings */
  12. font: inherit;
  13. /* Disable default rendering */
  14. appearance: none;
  15. background: none;
  16. padding: 5px;
  17. border: 1px solid rgb(192, 192, 192);
  18. border-radius: 5px;
  19. color: black;
  20. --bg-gradient: linear-gradient(to top, rgb(255, 255, 255) 80%, rgb(240, 240, 240));
  21. background-image: var(--bg-gradient);
  22. }
  23. /*
  24. * Buttons
  25. */
  26. input[type=button],
  27. input[type=color],
  28. input[type=image],
  29. input[type=reset],
  30. input[type=submit],
  31. input::file-selector-button,
  32. button,
  33. select {
  34. border-bottom-width: 2px;
  35. /* This avoids it jumping around when :active */
  36. vertical-align: middle;
  37. margin-top: 0;
  38. padding-left: 20px;
  39. padding-right: 20px;
  40. /* Disable Chrome's touch tap highlight */
  41. -webkit-tap-highlight-color: transparent;
  42. }
  43. /*
  44. * Select dropdowns
  45. */
  46. select {
  47. --select-arrow: url('data:image/svg+xml;utf8, \
  48. <svg width="8" height="6" version="1.1" viewBox="0 0 8 6" \
  49. xmlns="http://www.w3.org/2000/svg"> \
  50. <path d="m6.5 1.5 -2.5 3 -2.5 -3 5 0" stroke-width="3" \
  51. stroke="rgb(31,31,31)" fill="none" \
  52. stroke-linecap="round" stroke-linejoin="round" /> \
  53. </svg>');
  54. background-image: var(--select-arrow), var(--bg-gradient);
  55. background-position: calc(100% - 7px), left top;
  56. background-repeat: no-repeat;
  57. padding-right: calc(2*7px + 8px);
  58. padding-left: 7px;
  59. }
  60. /* FIXME: :active isn't set when the <select> is opened in Firefox:
  61. https://bugzilla.mozilla.org/show_bug.cgi?id=1805406 */
  62. select:active {
  63. /* Rotated arrow */
  64. background-image: url('data:image/svg+xml;utf8, \
  65. <svg width="8" height="6" version="1.1" viewBox="0 0 8 6" \
  66. xmlns="http://www.w3.org/2000/svg" transform="rotate(180)" > \
  67. <path d="m6.5 1.5 -2.5 3 -2.5 -3 5 0" stroke-width="3" \
  68. stroke="rgb(31,31,31)" fill="none" \
  69. stroke-linecap="round" stroke-linejoin="round" /> \
  70. </svg>'), var(--bg-gradient);
  71. }
  72. option {
  73. color: black;
  74. background: white;
  75. }
  76. /*
  77. * Checkboxes
  78. */
  79. input[type=checkbox] {
  80. display: inline-flex;
  81. justify-content: center;
  82. align-items: center;
  83. background-color: white;
  84. background-image: unset;
  85. border: 1px solid dimgrey;
  86. border-radius: 3px;
  87. width: 13px;
  88. height: 13px;
  89. padding: 0;
  90. margin-right: 6px;
  91. vertical-align: bottom;
  92. transition: 0.2s background-color linear;
  93. }
  94. input[type=checkbox]:checked {
  95. background-color: rgb(110, 132, 163);
  96. border-color: rgb(110, 132, 163);
  97. }
  98. input[type=checkbox]:checked::after {
  99. content: "";
  100. display: block; /* width & height doesn't work on inline elements */
  101. width: 3px;
  102. height: 7px;
  103. border: 1px solid white;
  104. border-width: 0 2px 2px 0;
  105. transform: rotate(40deg) translateY(-1px);
  106. }
  107. /*
  108. * Radiobuttons
  109. */
  110. input[type=radio] {
  111. border-radius: 50%;
  112. border: 1px solid dimgrey;
  113. width: 12px;
  114. height: 12px;
  115. padding: 0;
  116. margin-right: 6px;
  117. transition: 0.2s border linear;
  118. }
  119. input[type=radio]:checked {
  120. border: 6px solid rgb(110, 132, 163);
  121. }
  122. /*
  123. * Range sliders
  124. */
  125. input[type=range] {
  126. border: unset;
  127. border-radius: 3px;
  128. height: 20px;
  129. padding: 0;
  130. background: transparent;
  131. }
  132. /* -webkit-slider.. & -moz-range.. cant be in selector lists:
  133. https://bugs.chromium.org/p/chromium/issues/detail?id=1154623 */
  134. input[type=range]::-webkit-slider-runnable-track {
  135. background-color: rgb(110, 132, 163);
  136. height: 6px;
  137. border-radius: 3px;
  138. }
  139. input[type=range]::-moz-range-track {
  140. background-color: rgb(110, 132, 163);
  141. height: 6px;
  142. border-radius: 3px;
  143. }
  144. input[type=range]::-webkit-slider-thumb {
  145. appearance: none;
  146. width: 18px;
  147. height: 20px;
  148. border-radius: 5px;
  149. background-color: white;
  150. border: 1px solid dimgray;
  151. margin-top: -7px;
  152. }
  153. input[type=range]::-moz-range-thumb {
  154. appearance: none;
  155. width: 18px;
  156. height: 20px;
  157. border-radius: 5px;
  158. background-color: white;
  159. border: 1px solid dimgray;
  160. margin-top: -7px;
  161. }
  162. /*
  163. * File choosers
  164. */
  165. input[type=file] {
  166. background-image: none;
  167. border: none;
  168. }
  169. input::file-selector-button {
  170. margin-right: 6px;
  171. }
  172. /*
  173. * Hover
  174. */
  175. input[type=button]:hover,
  176. input[type=color]:hover,
  177. input[type=image]:hover,
  178. input[type=reset]:hover,
  179. input[type=submit]:hover,
  180. input::file-selector-button:hover,
  181. button:hover {
  182. background-image: linear-gradient(to top, rgb(255, 255, 255), rgb(250, 250, 250));
  183. }
  184. select:hover {
  185. background-image: var(--select-arrow),
  186. linear-gradient(to top, rgb(255, 255, 255), rgb(250, 250, 250));
  187. background-position: calc(100% - 7px), left top;
  188. background-repeat: no-repeat;
  189. }
  190. @media (any-pointer: coarse) {
  191. /* We don't want a hover style after touch input */
  192. input[type=button]:hover,
  193. input[type=color]:hover,
  194. input[type=image]:hover,
  195. input[type=reset]:hover,
  196. input[type=submit]:hover,
  197. input::file-selector-button:hover,
  198. button:hover {
  199. background-image: var(--bg-gradient);
  200. }
  201. select:hover {
  202. background-image: var(--select-arrow), var(--bg-gradient);
  203. }
  204. }
  205. /*
  206. * Active (clicked)
  207. */
  208. input[type=button]:active,
  209. input[type=color]:active,
  210. input[type=image]:active,
  211. input[type=reset]:active,
  212. input[type=submit]:active,
  213. input::file-selector-button:active,
  214. button:active,
  215. select:active {
  216. border-bottom-width: 1px;
  217. margin-top: 1px;
  218. }
  219. /*
  220. * Focus (tab)
  221. */
  222. input:focus-visible,
  223. input:focus-visible::file-selector-button,
  224. button:focus-visible,
  225. select:focus-visible,
  226. textarea:focus-visible {
  227. outline: 2px solid rgb(74, 144, 217);
  228. outline-offset: 1px;
  229. }
  230. input[type=file]:focus-visible {
  231. outline: none; /* We outline the button instead of the entire element */
  232. }
  233. /*
  234. * Disabled
  235. */
  236. input:disabled,
  237. input:disabled::file-selector-button,
  238. button:disabled,
  239. select:disabled,
  240. textarea:disabled {
  241. opacity: 0.4;
  242. }
  243. input[type=button]:disabled,
  244. input[type=color]:disabled,
  245. input[type=image]:disabled,
  246. input[type=reset]:disabled,
  247. input[type=submit]:disabled,
  248. input:disabled::file-selector-button,
  249. button:disabled,
  250. select:disabled {
  251. background-image: var(--bg-gradient);
  252. border-bottom-width: 2px;
  253. margin-top: 0;
  254. }
  255. input[type=file]:disabled {
  256. background-image: none;
  257. }
  258. select:disabled {
  259. background-image: var(--select-arrow), var(--bg-gradient);
  260. }
  261. input[type=image]:disabled {
  262. /* See Firefox bug:
  263. https://bugzilla.mozilla.org/show_bug.cgi?id=1798304 */
  264. cursor: default;
  265. }