Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -190,51 +190,47 @@ st.markdown(
|
|
| 190 |
# 고정 이미지 URL
|
| 191 |
#BG_URL = "https://plus.unsplash.com/premium_photo-1679830513869-cd3648acb1db?q=80&w=2127&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
|
| 192 |
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
st.
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
/*
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
.
|
| 211 |
-
.
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
z-index: 1;
|
| 235 |
-
}}
|
| 236 |
-
</style>
|
| 237 |
-
""", unsafe_allow_html=True)
|
| 238 |
|
| 239 |
|
| 240 |
|
|
|
|
| 190 |
# 고정 이미지 URL
|
| 191 |
#BG_URL = "https://plus.unsplash.com/premium_photo-1679830513869-cd3648acb1db?q=80&w=2127&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
|
| 192 |
|
| 193 |
+
# === 배경 설정 UI ===
|
| 194 |
+
st.sidebar.subheader("🎨 배경 설정")
|
| 195 |
+
st.sidebar.toggle("배경 이미지 사용", key="bg_on", value=True)
|
| 196 |
+
|
| 197 |
+
def apply_background(): # 보호: 기존 ::before 배경이 있으면 끄기 (겹침/끊김 방지)
|
| 198 |
+
base_reset_css = """
|
| 199 |
+
<style>
|
| 200 |
+
.stApp::before, .block-container::before{ content:none !important; }
|
| 201 |
+
/* 컨텐츠/사이드바는 배경 레이어 위에 오도록 */
|
| 202 |
+
.block-container, [data-testid="stSidebar"]{ position:relative; z-index:1; }
|
| 203 |
+
/* 입력박스 아래 여백 (요청 2번) */
|
| 204 |
+
div[data-testid="stTextInput"]{ margin-bottom:18px !important; }
|
| 205 |
+
</style>
|
| 206 |
+
"""
|
| 207 |
+
|
| 208 |
+
st.markdown(base_reset_css, unsafe_allow_html=True)
|
| 209 |
+
if st.session_state.get("bg_on") and st.session_state.get("bg_url"):
|
| 210 |
+
url = st.session_state["bg_url"] # 0~1 로 변환 (흰 오버레이로 밝기/가독성 조절)
|
| 211 |
+
overlay_alpha = float(st.session_state.get("bg_overlay_pct", 15)) / 100.0 # ✅ 이미지 배경 (끊김 방지: 페이지 전체 .stApp에 고정 배경)
|
| 212 |
+
st.markdown(f"""
|
| 213 |
+
<style>
|
| 214 |
+
.stApp{{ background: url('{url}') center / cover no-repeat fixed; }}
|
| 215 |
+
/* 오버레이: 이미지 위에 흰색 막을 얹어 가독성 확보 (투명도 조절 가능) */
|
| 216 |
+
.stApp::after{{ content:""; position:fixed; inset:0; z-index:0; pointer-events:none; background: rgba(255,255,255,{overlay_alpha}); }}
|
| 217 |
+
/* 모바일은 fixed 이슈가 있어 고정 해제 */
|
| 218 |
+
|
| 219 |
+
@media (max-width:768px){{ .stApp{{ background-attachment: initial; }}
|
| 220 |
+
}}
|
| 221 |
+
</style>
|
| 222 |
+
""", unsafe_allow_html=True)
|
| 223 |
+
else:
|
| 224 |
+
# ✅ 단색 배경 (끊김 없음: 요소 자체의 background-color 사용)
|
| 225 |
+
color = st.session_state.get("bg_color", "#F1F1F1")
|
| 226 |
+
st.markdown(f"""
|
| 227 |
+
<style>
|
| 228 |
+
.stApp{{ background-color: {color} !important; }}
|
| 229 |
+
</style>
|
| 230 |
+
""", unsafe_allow_html=True)
|
| 231 |
+
|
| 232 |
+
# 호출
|
| 233 |
+
apply_background()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 234 |
|
| 235 |
|
| 236 |
|