class Style: @staticmethod def get_css(): """返回應用程式的 CSS 樣式""" css = """ body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; background: linear-gradient(135deg, #e0f7fa, #b2ebf2); margin: 0; padding: 0; display: flex; justify-content: center; min-height: 100vh; } .gradio-container { max-width: 1200px !important; margin: 0 auto; /* 確保容器居中 */ padding: 1rem; width: 100%; } .app-header { text-align: center; margin-bottom: 2rem; background: rgba(255, 255, 255, 0.8); padding: 1.5rem; border-radius: 10px; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); width: 100%; } .app-title { color: #2D3748; font-size: 2.5rem; margin-bottom: 0.5rem; background: linear-gradient(90deg, #38b2ac, #4299e1); -webkit-background-clip: text; -webkit-text-fill-color: transparent; } .app-subtitle { color: #4A5568; font-size: 1.2rem; font-weight: normal; margin-top: 0.25rem; } .app-divider { width: 80px; height: 3px; background: linear-gradient(90deg, #38b2ac, #4299e1); margin: 1rem auto; } .input-panel, .output-panel { background: white; border-radius: 10px; padding: 1.5rem; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08); margin: 0 auto 1rem auto; /* 確保面板居中 */ } /* 改變灰色背景為更好看的漸變色 */ .how-to-use { background: linear-gradient(135deg, #f6f9fc, #edf2f7); border-radius: 10px; padding: 1.5rem; margin-top: 1rem; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05); color: #2d3748; } .detect-btn { background: linear-gradient(90deg, #38b2ac, #4299e1) !important; color: white !important; border: none !important; border-radius: 8px !important; transition: transform 0.3s, box-shadow 0.3s !important; font-weight: bold !important; letter-spacing: 0.5px !important; padding: 0.75rem 1.5rem !important; width: 100%; margin: 1rem auto !important; } .detect-btn:hover { transform: translateY(-2px) !important; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2) !important; } .detect-btn:active { transform: translateY(1px) !important; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2) !important; } /* 確保標籤和內容都置中 */ .gr-form, .gr-box, .gr-panel { display: flex; flex-direction: column; align-items: center; width: 100%; margin: 0 auto; } /* 確保圖像上傳界面居中 */ .upload-box { margin: 0 auto; text-align: center; max-width: 500px; } .footer { text-align: center; margin-top: 2rem; font-size: 0.9rem; color: #4A5568; padding: 1rem; background: rgba(255, 255, 255, 0.5); border-radius: 10px; width: 100%; } /* 中央對齊所有容器 */ .container, .gr-container, .gr-row, .gr-col { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; } /* 改善標籤頁樣式 */ .tabs { width: 100%; display: flex; justify-content: center; } /* 改善表單和控制項置中 */ label, button, select, .gr-input, .gr-button, .gr-checkbox, .gr-radio, .gr-slider { margin-left: auto; margin-right: auto; } /* 響應式調整 */ @media (max-width: 768px) { .app-title { font-size: 2rem; } .app-subtitle { font-size: 1rem; } .gradio-container { padding: 0.5rem; } } """ return css