style.css 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. * {
  2. box-sizing: border-box;
  3. }
  4. :root {
  5. --darkest: #171B19;
  6. --dark: #1D2B26;
  7. --med: #2D3B36;
  8. --light: #39574C;
  9. --lightest: #475650;
  10. --size-scale: 50;
  11. --size-scale-px: calc(var(--size-scale) * 1px);
  12. }
  13. body {
  14. margin: 0;
  15. min-height: 100vh;
  16. background-color: var(--light);
  17. color: var(--darkest);
  18. /* 為文字顏色添加一個變量 */
  19. font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  20. /* 選擇一個基本字體 */
  21. padding-top: 40px;
  22. }
  23. header {
  24. background-color: var(--darkest);
  25. color: var(--lightest);
  26. padding: 0.25em;
  27. display: flex;
  28. justify-content: space-between;
  29. align-items: center;
  30. position: fixed; /* 固定頭部的位置 */
  31. top: 0; /* 距離視口頂部的距離 */
  32. left: 0; /* 距離視口左邊的距離 */
  33. width: 100%; /* 頭部寬度 */
  34. z-index: 1000; /* 確保頭部在其他內容之上 */
  35. /* 垂直居中對齊 */
  36. }
  37. header h1 {
  38. margin: 0;
  39. padding: 0;
  40. font-size: 1.5em;
  41. }
  42. .displayNone {
  43. display: none;
  44. }
  45. .card {
  46. display: inline-block;
  47. background: var(--lightest);
  48. box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  49. border-radius: 5px;
  50. /* 卡片圓角 */
  51. overflow: hidden;
  52. max-width: 350px;
  53. /* 最大寬度設定 */
  54. margin: 8px;
  55. /* 卡片之間的間隔 */
  56. }
  57. .card-size-1 {
  58. width: calc(150px - 20px);
  59. }
  60. /* 調整寬度以補償邊距 */
  61. .card-size-2 {
  62. width: calc(200px - 20px);
  63. }
  64. .card-size-3 {
  65. width: calc(250px - 20px);
  66. }
  67. .card-size-4 {
  68. width: calc(300px - 20px);
  69. }
  70. .mood-image {
  71. width: 100%;
  72. /* 使圖片寬度適應容器 */
  73. height: auto;
  74. /* 高度自動 */
  75. object-fit: cover;
  76. /* 保持圖片比例,並填滿整個格子 */
  77. border-radius: 5px;
  78. /* 圖片圓角 */
  79. }
  80. /* 模態視窗背景樣式 */
  81. .modal {
  82. display: none;
  83. /* Hidden by default */
  84. position: fixed;
  85. /* Stay in place */
  86. z-index: 4;
  87. /* Sit on top */
  88. left: 0;
  89. top: 0;
  90. width: 100%;
  91. /* Full width */
  92. height: 100%;
  93. /* Full height */
  94. overflow: auto;
  95. /* Enable scroll if needed */
  96. background-color: rgb(0, 0, 0);
  97. /* Fallback color */
  98. background-color: rgba(0, 0, 0, 0.4);
  99. /* Black w/ opacity */
  100. }
  101. /* 模態視窗內容樣式 */
  102. .modal-content {
  103. background-color: #fefefe;
  104. margin: 15% auto;
  105. /* 15% from the top and centered */
  106. padding: 20px;
  107. border: 1px solid #888;
  108. width: 80%;
  109. /* Could be more or less, depending on screen size */
  110. }
  111. /* The Close Button */
  112. .close {
  113. color: #aaa;
  114. float: right;
  115. font-size: 28px;
  116. font-weight: bold;
  117. }
  118. .close:hover,
  119. .close:focus {
  120. color: black;
  121. text-decoration: none;
  122. cursor: pointer;
  123. }
  124. .mood-image-small {
  125. transform: scale(0.9);
  126. /* 縮小圖片 */
  127. transition: transform 0.3s ease;
  128. /* 平滑過渡效果 */
  129. }
  130. .card-buttons {
  131. position: absolute;
  132. top: 0;
  133. right: 0;
  134. display: none;
  135. flex-direction: column;
  136. align-items: flex-end;
  137. height: 100%;
  138. padding: 10px;
  139. }
  140. .button-group {
  141. display: flex;
  142. margin-bottom: -10px;
  143. }
  144. .button-group.vertical {
  145. flex-direction: column;
  146. margin-right: -27px;
  147. margin-top: -8px;
  148. }
  149. .button-group.horizontal {
  150. flex-direction: row;
  151. position: absolute;
  152. bottom: 10px;
  153. margin-left: -45px;
  154. transform: translateX(-50%);
  155. }
  156. .button {
  157. margin: 4px;
  158. /* 為按鈕添加一些空間 */
  159. }
  160. .card .button {
  161. padding: 0.3em 0.6em;
  162. /* 按鈕的內邊距,使用 em 單位 */
  163. margin: 0.1em;
  164. /* 按鈕之間的外邊距,使用 em 單位 */
  165. border: none;
  166. border-radius: 5px;
  167. /* 圓角 */
  168. background-color: var(--med);
  169. /* 使用 CSS 變量設定背景色 */
  170. color: white;
  171. cursor: pointer;
  172. line-height: 1;
  173. /* 行高與按鈕大小相匹配 */
  174. white-space: nowrap;
  175. /* 防止圖示換行 */
  176. }
  177. .button:hover {
  178. background-color: var(--dark);
  179. /* 滑鼠懸停時的背景色 */
  180. }
  181. /* Tabler 圖示的基本樣式 */
  182. .tabler-icon {
  183. display: inline-block;
  184. vertical-align: middle;
  185. }
  186. .card-selected .card-buttons {
  187. display: flex;
  188. /* 顯示按鈕 */
  189. }
  190. /* 根據卡片大小設定按鈕尺寸的樣式 */
  191. .card-size-1 .card-buttons {
  192. font-size: 4vw;
  193. }
  194. .card-size-2 .card-buttons {
  195. font-size: 3.5vw;
  196. }
  197. .card-size-3 .card-buttons {
  198. font-size: 3vw;
  199. }
  200. .card-size-4 .card-buttons {
  201. font-size: 2.5vw;
  202. }
  203. /* 卡片縮小時的轉換效果 */
  204. .card-selected .mood-image {
  205. transform: scale(0.7);
  206. /* 縮小圖片 */
  207. transform-origin: top left;
  208. /* 從左上角開始縮放 */
  209. transition: transform 0.3s ease;
  210. /* 平滑過渡效果 */
  211. }
  212. /* 卡片被選中時的樣式 */
  213. .card-selected .mood-image {
  214. transform-origin: top left;
  215. transform: scale(0.7);
  216. transition: transform 0.3s ease;
  217. }
  218. /* 卡片被選中時顯示按鈕 */
  219. .card-selected .card-buttons {
  220. display: flex;
  221. justify-content: space-around;
  222. position: absolute;
  223. width: calc(100% - 20px);
  224. /* 考慮到 padding */
  225. bottom: 5px;
  226. left: 10px;
  227. }