ticker.html 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8"/>
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
  6. <title>腾图滚动条</title>
  7. <style>
  8. /* 滚动条窗口:整行可拖动,透明背景 */
  9. * { box-sizing: border-box; }
  10. html, body {
  11. margin: 0;
  12. height: 100%;
  13. overflow: hidden;
  14. background: transparent;
  15. font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  16. -webkit-user-select: none;
  17. user-select: none;
  18. }
  19. /* 容器:整行拖动窗口;默认半透明底,透明模式完全透明不遮挡内容 */
  20. .ticker {
  21. display: flex;
  22. align-items: center;
  23. height: 100vh;
  24. overflow: hidden;
  25. border-radius: 8px;
  26. background: rgba(10, 12, 24, 0.72);
  27. backdrop-filter: blur(8px);
  28. -webkit-backdrop-filter: blur(8px);
  29. --wails-draggable: drag; /* 整行可拖动窗口 */
  30. cursor: move;
  31. }
  32. .ticker.transparent {
  33. background: transparent; /* 背景透明,不遮挡下方内容 */
  34. backdrop-filter: none;
  35. -webkit-backdrop-filter: none;
  36. text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); /* 文字加投影保证可读 */
  37. }
  38. /* 滚动视口:占满剩余宽度,超出部分隐藏(轨道动画在内部平移) */
  39. .ticker-viewport {
  40. flex: 1;
  41. min-width: 0;
  42. height: 100%;
  43. overflow: hidden;
  44. }
  45. /* 滚动轨道:内容复制两份实现无缝循环,动画时长由 JS 按速度计算 */
  46. .ticker-track {
  47. display: inline-flex;
  48. align-items: center;
  49. white-space: nowrap;
  50. animation: ticker-scroll linear infinite;
  51. will-change: transform;
  52. }
  53. @keyframes ticker-scroll {
  54. from { transform: translateX(0); }
  55. to { transform: translateX(-50%); } /* 内容两份,平移一半即循环 */
  56. }
  57. .ticker-item {
  58. display: inline-flex;
  59. align-items: center;
  60. gap: 6px;
  61. padding: 0 18px;
  62. line-height: 1;
  63. font-variant-numeric: tabular-nums;
  64. }
  65. .ticker-item a {
  66. color: inherit;
  67. text-decoration: none;
  68. cursor: pointer;
  69. --wails-draggable: no-drag; /* 链接可点击,不触发拖动 */
  70. }
  71. .ticker-item a:hover { text-decoration: underline; }
  72. .up { color: #ff5a5a; } /* 红涨 */
  73. .down { color: #3ddc84; } /* 绿跌 */
  74. .src { opacity: 0.55; font-size: 0.85em; } /* 新闻来源小标签 */
  75. /* 右侧控制按钮:阅读(TTS 朗读新闻标题)与关闭(停止滚动条) */
  76. .ticker-actions {
  77. display: flex;
  78. align-items: center;
  79. gap: 4px;
  80. flex-shrink: 0;
  81. padding: 0 8px;
  82. --wails-draggable: no-drag; /* 按钮可点击,不触发拖动 */
  83. }
  84. .ticker-actions button {
  85. display: inline-flex;
  86. align-items: center;
  87. justify-content: center;
  88. min-width: 22px;
  89. height: 22px;
  90. padding: 0 6px;
  91. border: 1px solid rgba(255, 255, 255, 0.18);
  92. border-radius: 6px;
  93. background: rgba(255, 255, 255, 0.10);
  94. color: #fff;
  95. font-size: 13px;
  96. line-height: 1;
  97. cursor: pointer;
  98. transition: background 0.15s ease;
  99. }
  100. .ticker-actions button:hover { background: rgba(255, 255, 255, 0.22); }
  101. .ticker-actions button.is-active { background: rgba(255, 77, 77, 0.55); border-color: rgba(255, 77, 77, 0.8); }
  102. /* 新闻标题行当前被朗读:高亮 */
  103. .ticker-item.speaking { color: #ffe08a; text-shadow: 0 0 6px rgba(255, 224, 138, 0.6); }
  104. </style>
  105. </head>
  106. <body>
  107. <div class="ticker" id="ticker">
  108. <div class="ticker-viewport" id="viewport">
  109. <div class="ticker-track" id="track"></div>
  110. </div>
  111. <div class="ticker-actions" id="actions">
  112. <button id="btn-read" title="朗读新闻标题">读</button>
  113. <button id="btn-close" title="关闭滚动条">×</button>
  114. </div>
  115. </div>
  116. <script type="module" src="/src/ticker.js"></script>
  117. </body>
  118. </html>