image_satirical_cartoon.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="template:media-width" content="1024">
  6. <meta name="template:media-height" content="1024">
  7. <meta name="viewport" content="width=1080, height=1920">
  8. <title>80年代讽刺漫画风格 全屏图片 只有标题 - 1080x1920</title>
  9. <!-- Google Fonts - 中文字体 -->
  10. <link rel="preconnect" href="https://fonts.googleapis.com">
  11. <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
  12. <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;700;900&family=Noto+Serif+SC:wght@400;700;900&family=Liu+Jian+Mao+Cao&family=Ma+Shan+Zheng&display=swap" rel="stylesheet">
  13. <style>
  14. * { margin: 0; padding: 0; box-sizing: border-box; }
  15. html, body { width: 1080px; height: 1920px; overflow: hidden; }
  16. body {
  17. font-family: 'Noto Sans SC', 'PingFang SC', 'Source Han Sans', 'Microsoft YaHei', -apple-system, BlinkMacSystemFont, sans-serif;
  18. color: #fff;
  19. position: relative;
  20. background: transparent; /* 移除黑色背景 */
  21. }
  22. /* 背景使用图片并做模糊处理,完全覆盖整个页面 */
  23. .bg {
  24. position: relative;
  25. width: 100%;
  26. height: 100%;
  27. background-image: url("{{image}}");
  28. background-size: cover;
  29. background-position: center;
  30. z-index: 0;
  31. display: flex;
  32. justify-content: center;
  33. align-items: center;
  34. }
  35. .title {
  36. width: 900px;
  37. text-align: center;
  38. font-size: 92px;
  39. font-weight: 800;
  40. line-height: 1.2;
  41. text-shadow: 0 6px 22px rgba(0,0,0,0.6),
  42. -2px -2px 0 #000,
  43. 2px -2px 0 #000,
  44. -2px 2px 0 #000,
  45. 2px 2px 0 #000;
  46. letter-spacing: 4px;
  47. /* 确保文本不会溢出 */
  48. word-wrap: break-word;
  49. overflow-wrap: break-word;
  50. white-space: nowrap;
  51. }
  52. /* Footer */
  53. .footer {
  54. display: flex;
  55. align-items: center;
  56. justify-content: space-between;
  57. width: 100%;
  58. padding: 25px 20px 0 20px;
  59. position: absolute;
  60. bottom: 20px;
  61. color: #fff;
  62. text-shadow: -1px -1px 0 #000,
  63. 1px -1px 0 #000,
  64. -1px 1px 0 #000,
  65. 1px 1px 0 #000;
  66. }
  67. .author {
  68. display: flex;
  69. flex-direction: column;
  70. gap: 6px;
  71. letter-spacing: 2px;
  72. }
  73. .author-name {
  74. font-size: 30px;
  75. font-weight: 600;
  76. display: flex;
  77. align-items: center;
  78. gap: 10px;
  79. }
  80. .author-mark {
  81. width: 8px;
  82. height: 8px;
  83. /* border-radius: 50%; */
  84. /* background: rgba(149, 165, 166, 0.7); */
  85. }
  86. .author-desc {
  87. font-size: 22px;
  88. /* color: #5d6d7e; */
  89. line-height: 1.3;
  90. font-weight: 400;
  91. }
  92. .logo-section {
  93. display: flex;
  94. flex-direction: column;
  95. align-items: flex-end;
  96. gap: 8px;
  97. }
  98. .logo {
  99. font-size: 24px;
  100. font-weight: 500;
  101. }
  102. .logo-marks {
  103. display: flex;
  104. gap: 5px;
  105. }
  106. .logo-mark {
  107. width: 6px;
  108. height: 6px;
  109. border-radius: 50%;
  110. background: rgba(149, 165, 166, 0.45);
  111. }
  112. .logo-mark.active {
  113. background: rgba(149, 165, 166, 0.75);
  114. }
  115. </style>
  116. </head>
  117. <body>
  118. <div class="bg">
  119. <div class="title">{{title}}</div>
  120. </div>
  121. <div class="footer">
  122. <div class="author">
  123. <div class="author-name">
  124. <span class="author-mark"></span>
  125. <div class="logo">{{author=@Pixelle.AI}}</div>
  126. </div>
  127. <div class="author-desc">{{describe=Open Source Omnimodal AI Creative Agent}}</div>
  128. </div>
  129. <div class="logo-section">
  130. <div class="logo">{{brand=Pixelle-Video}}</div>
  131. <div class="logo-marks">
  132. <div class="logo-mark"></div>
  133. <div class="logo-mark active"></div>
  134. <div class="logo-mark"></div>
  135. <div class="logo-mark"></div>
  136. </div>
  137. </div>
  138. </div>
  139. <script>
  140. /**
  141. * 根据文本宽度自动调整字体大小
  142. * @param {HTMLElement} element - 要调整的元素
  143. * @param {number} maxWidth - 最大宽度(px)
  144. * @param {number} minFontSize - 最小字体大小(px)
  145. * @param {number} maxFontSize - 最大字体大小(px)
  146. */
  147. function autoFitFontSize(element, maxWidth, minFontSize, maxFontSize) {
  148. try {
  149. if (!element || !element.textContent || !element.textContent.trim()) {
  150. return;
  151. }
  152. if (!document.body) {
  153. return;
  154. }
  155. // 创建一个临时的测量元素
  156. const measure = document.createElement('span');
  157. measure.style.visibility = 'hidden';
  158. measure.style.position = 'absolute';
  159. measure.style.top = '-9999px';
  160. measure.style.left = '-9999px';
  161. measure.style.whiteSpace = 'nowrap';
  162. // 复制元素的样式
  163. const computedStyle = window.getComputedStyle(element);
  164. measure.style.fontFamily = computedStyle.fontFamily;
  165. measure.style.fontSize = computedStyle.fontSize;
  166. measure.style.fontWeight = computedStyle.fontWeight;
  167. measure.style.letterSpacing = computedStyle.letterSpacing;
  168. measure.textContent = element.textContent;
  169. document.body.appendChild(measure);
  170. // 二分查找合适的字体大小
  171. let low = minFontSize;
  172. let high = maxFontSize;
  173. let bestSize = maxFontSize;
  174. // 先检查最大字体是否合适
  175. measure.style.fontSize = maxFontSize + 'px';
  176. if (measure.offsetWidth <= maxWidth) {
  177. bestSize = maxFontSize;
  178. } else {
  179. // 使用二分查找
  180. while (high - low > 0.5) {
  181. const mid = (low + high) / 2;
  182. measure.style.fontSize = mid + 'px';
  183. if (measure.offsetWidth <= maxWidth) {
  184. bestSize = mid;
  185. low = mid;
  186. } else {
  187. high = mid;
  188. }
  189. }
  190. }
  191. // 应用找到的字体大小
  192. element.style.fontSize = bestSize + 'px';
  193. // 清理临时元素
  194. if (measure.parentNode) {
  195. document.body.removeChild(measure);
  196. }
  197. } catch (error) {
  198. console.error('自动调整字体大小出错:', error);
  199. }
  200. }
  201. // 页面加载完成后自动调整字体大小
  202. function initAutoFit() {
  203. try {
  204. const titleElement = document.querySelector('.title');
  205. if (titleElement) {
  206. // 获取容器的实际宽度
  207. const maxWidth = 900;
  208. // 自动调整字体大小:最小12px,最大72px
  209. autoFitFontSize(titleElement, maxWidth, 12, 72);
  210. }
  211. } catch (error) {
  212. console.error('初始化自动调整字体大小出错:', error);
  213. }
  214. }
  215. // 等待 DOM 加载完成
  216. if (document.readyState === 'loading') {
  217. document.addEventListener('DOMContentLoaded', initAutoFit);
  218. } else {
  219. // DOM 已经加载完成
  220. initAutoFit();
  221. }
  222. // 如果内容是通过模板引擎动态插入的,可以监听内容变化
  223. // 使用 MutationObserver 监听文本变化
  224. if (typeof MutationObserver !== 'undefined') {
  225. try {
  226. const observer = new MutationObserver(function(mutations) {
  227. let shouldUpdate = false;
  228. mutations.forEach(function(mutation) {
  229. if (mutation.type === 'childList' || mutation.type === 'characterData') {
  230. shouldUpdate = true;
  231. }
  232. });
  233. if (shouldUpdate) {
  234. // 延迟执行,避免频繁调用
  235. setTimeout(initAutoFit, 100);
  236. }
  237. });
  238. // 等待 body 元素存在后再观察
  239. if (document.body) {
  240. observer.observe(document.body, {
  241. childList: true,
  242. subtree: true,
  243. characterData: true
  244. });
  245. } else {
  246. document.addEventListener('DOMContentLoaded', function() {
  247. if (document.body) {
  248. observer.observe(document.body, {
  249. childList: true,
  250. subtree: true,
  251. characterData: true
  252. });
  253. }
  254. });
  255. }
  256. } catch (error) {
  257. console.error('设置 MutationObserver 出错:', error);
  258. }
  259. }
  260. </script>
  261. </body>
  262. </html>