code-slicer commited on
Commit
42fdee1
Β·
verified Β·
1 Parent(s): 87ca6ec

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +42 -19
app.py CHANGED
@@ -197,44 +197,67 @@ st.sidebar.toggle("λ°°κ²½ 이미지 μ‚¬μš©", key="bg_on", value=False)
197
  if not st.session_state.get("bg_on"):
198
  st.sidebar.color_picker("단색 λ°°κ²½", value=st.session_state.get("bg_color", "#F1F1F1"), key="bg_color")
199
 
200
- # === 배경 적용 ===
201
- def apply_background():
202
- # 1) κΈ°λ³Έ 리셋 (κ²ΉμΉ¨ λ°©μ§€: κΈ°μ‘΄ ::before 끄기)
 
203
  st.markdown("""
204
  <style>
 
205
  .stApp::before, .block-container::before { content: none !important; }
206
- /* μ½˜ν…μΈ λŠ” 항상 λ°°κ²½ μœ„μ— */
207
- .block-container, [data-testid="stSidebar"] { position: relative; z-index: 1; }
208
- /* μž…λ ₯λ°•μŠ€ ν•˜λ‹¨ μ—¬λ°± */
209
  div[data-testid="stTextInput"] { margin-bottom: 18px !important; }
 
 
 
 
 
 
 
 
 
 
 
210
  </style>
211
  """, unsafe_allow_html=True)
212
 
213
  if st.session_state.get("bg_on"):
214
- # 2) 이미지 λ°°κ²½: 배경만 희석(μ½˜ν…μΈ λŠ” 뢈투λͺ… μœ μ§€)
215
  st.markdown(f"""
216
  <style>
217
- .stApp {{
218
- background-attachment: fixed;
219
- background-position: center 45% !important;
220
- background-size: cover;
221
- background-repeat: no-repeat;
222
- /* overlay(흰색 85% 투λͺ…) + μ‹€μ œ 이미지 */
223
  background-image:
224
  linear-gradient(rgba(255,255,255,0.85), rgba(255,255,255,0.85)),
225
- url('{BG_URL}');
 
 
 
 
226
  }}
227
- @media (max-width:768px) {{
228
- .stApp {{ background-attachment: initial; }}
 
 
 
 
 
229
  }}
230
  </style>
231
  """, unsafe_allow_html=True)
232
  else:
233
- # 3) 단색 λ°°κ²½: 이전 이미지 μž”μ‘΄ 차단
234
  color = st.session_state.get("bg_color", "#F1F1F1")
235
  st.markdown(f"""
236
  <style>
237
- .stApp {{
 
 
 
 
238
  background-image: none !important;
239
  background-color: {color} !important;
240
  }}
@@ -242,7 +265,7 @@ def apply_background():
242
  """, unsafe_allow_html=True)
243
 
244
  # 호좜
245
- apply_background()
246
 
247
  # ── P κΈ€κΌ΄ 크기 14 px ───────────────────────────────────
248
  st.markdown("""
 
197
  if not st.session_state.get("bg_on"):
198
  st.sidebar.color_picker("단색 λ°°κ²½", value=st.session_state.get("bg_color", "#F1F1F1"), key="bg_color")
199
 
200
+
201
+ # === 쀑앙 μ»¨ν…Œμ΄λ„ˆ(λ³Έλ¬Έ)μ—λ§Œ λ°°κ²½ 적용 ===
202
+ def apply_background_center_only():
203
+ # 베이슀 리셋: 전체 λ°°κ²½ 제거 + κΈ°λ³Έ μ—¬λ°±/λ ˆμ΄μ–΄ 정리
204
  st.markdown("""
205
  <style>
206
+ .stApp { background: none !important; }
207
  .stApp::before, .block-container::before { content: none !important; }
208
+ [data-testid="stSidebar"] { position: relative; z-index: 1; }
 
 
209
  div[data-testid="stTextInput"] { margin-bottom: 18px !important; }
210
+
211
+ /* 쀑앙 μ»¨ν…Œμ΄λ„ˆ(.main)만 νƒ€κ²Ÿ – 버전 차이 포괄 */
212
+ :is(
213
+ [data-testid="stAppViewContainer"] > .main,
214
+ section.main,
215
+ main[data-testid="stMain"]
216
+ ){
217
+ position: relative;
218
+ isolation: isolate;
219
+ min-height: 100vh; /* ν™”λ©΄ 가득 μ±„μ›Œ λ°°κ²½ 곡백 λ°©μ§€ */
220
+ }
221
  </style>
222
  """, unsafe_allow_html=True)
223
 
224
  if st.session_state.get("bg_on"):
225
+ # 이미지 λ°°κ²½(쀑앙 μ»¨ν…Œμ΄λ„ˆμ—λ§Œ 적용)
226
  st.markdown(f"""
227
  <style>
228
+ :is(
229
+ [data-testid="stAppViewContainer"] > .main,
230
+ section.main,
231
+ main[data-testid="stMain"]
232
+ ){{
 
233
  background-image:
234
  linear-gradient(rgba(255,255,255,0.85), rgba(255,255,255,0.85)),
235
+ url('{BG_URL}') !important;
236
+ background-position: center 45% !important;
237
+ background-size: cover !important;
238
+ background-repeat: no-repeat !important;
239
+ background-attachment: scroll, fixed !important;
240
  }}
241
+
242
+ @media (max-width: 768px){{
243
+ :is(
244
+ [data-testid="stAppViewContainer"] > .main,
245
+ section.main,
246
+ main[data-testid="stMain"]
247
+ ){{ background-attachment: scroll, scroll !important; }}
248
  }}
249
  </style>
250
  """, unsafe_allow_html=True)
251
  else:
252
+ # 단색 λ°°κ²½(쀑앙 μ»¨ν…Œμ΄λ„ˆμ—λ§Œ 적용)
253
  color = st.session_state.get("bg_color", "#F1F1F1")
254
  st.markdown(f"""
255
  <style>
256
+ :is(
257
+ [data-testid="stAppViewContainer"] > .main,
258
+ section.main,
259
+ main[data-testid="stMain"]
260
+ ){{
261
  background-image: none !important;
262
  background-color: {color} !important;
263
  }}
 
265
  """, unsafe_allow_html=True)
266
 
267
  # 호좜
268
+ apply_background_center_only()
269
 
270
  # ── P κΈ€κΌ΄ 크기 14 px ───────────────────────────────────
271
  st.markdown("""