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