code-slicer commited on
Commit
a951ee4
ยท
verified ยท
1 Parent(s): 3480f07

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +46 -24
app.py CHANGED
@@ -199,56 +199,78 @@ if not st.session_state.get("bg_on"):
199
 
200
  # === ์ค‘์•™ ์ปจํ…Œ์ด๋„ˆ์—๋งŒ ๋ฐฐ๊ฒฝ ์ ์šฉ ===
201
  def apply_background_center_only():
202
- # ๋ฒ ์ด์Šค ๋ฆฌ์…‹: ์•ฑ ์ „์ฒด ๋ฐฐ๊ฒฝ ์ œ๊ฑฐ + ๊ธฐ๋ณธ ๋ ˆ์ด์•„์›ƒ ์ •๋ฆฌ
203
  st.markdown("""
204
  <style>
205
- .stApp { background: none !important; } /* ์ „์ฒด ๋ฐฐ๊ฒฝ ์ œ๊ฑฐ */
 
206
  .stApp::before, .block-container::before { content: none !important; }
207
- [data-testid="stSidebar"] { position: relative; z-index: 1; }
208
 
209
- /* ์ค‘์•™ ์ปจํ…Œ์ด๋„ˆ๊ฐ€ ์ž์ฒด ๋ ˆ์ด์–ด๋ฅผ ๊ฐ–๋„๋ก(์˜๋„์น˜ ์•Š์€ ๊ฒน์นจ ๋ฐฉ์ง€) */
210
- [data-testid="stAppViewContainer"] > .main .block-container {
 
 
 
 
 
 
211
  position: relative;
212
  isolation: isolate;
213
- overflow: hidden;
214
- min-height: 100vh;
 
 
 
 
215
  }
216
 
217
- /* ์ž…๋ ฅ๋ฐ•์Šค ํ•˜๋‹จ ์—ฌ๋ฐฑ(์š”์ฒญ์‚ฌํ•ญ ์œ ์ง€) */
218
- div[data-testid="stTextInput"] { margin-bottom: 18px !important; }
219
  </style>
220
  """, unsafe_allow_html=True)
221
 
 
222
  if st.session_state.get("bg_on"):
223
- # ์ด๋ฏธ์ง€ ๋ฐฐ๊ฒฝ: ์ค‘์•™ ์ปจํ…Œ์ด๋„ˆ์—๋งŒ ์ ์šฉ
224
  st.markdown(f"""
225
  <style>
226
- [data-testid="stAppViewContainer"] > .main .block-container {{
 
 
 
 
 
227
  background-image:
228
  linear-gradient(rgba(255,255,255,0.85), rgba(255,255,255,0.85)),
229
- url('{BG_URL}');
230
- background-position: center 45%;
231
- background-size: cover;
232
- background-repeat: no-repeat;
233
-
234
- /* ๋ ˆ์ด์–ด๋ณ„ attachment: ์˜ค๋ฒ„๋ ˆ์ด๋Š” scroll, ์ด๋ฏธ์ง€๋Š” fixed */
235
- background-attachment: scroll, fixed;
236
  }}
237
 
238
- /* ๋ชจ๋ฐ”์ผ์—์„œ fixed ์ด์Šˆ ํšŒํ”ผ */
239
- @media (max-width: 768px) {{
240
- [data-testid="stAppViewContainer"] > .main .block-container {{
241
- background-attachment: scroll, scroll;
 
 
 
 
 
242
  }}
243
  }}
244
  </style>
245
  """, unsafe_allow_html=True)
246
  else:
247
- # ๋‹จ์ƒ‰ ๋ฐฐ๊ฒฝ: ์ค‘์•™ ์ปจํ…Œ์ด๋„ˆ์—๋งŒ ์ƒ‰์ƒ ์ ์šฉ
248
  color = st.session_state.get("bg_color", "#F1F1F1")
249
  st.markdown(f"""
250
  <style>
251
- [data-testid="stAppViewContainer"] > .main .block-container {{
 
 
 
 
 
252
  background-image: none !important;
253
  background-color: {color} !important;
254
  }}
 
199
 
200
  # === ์ค‘์•™ ์ปจํ…Œ์ด๋„ˆ์—๋งŒ ๋ฐฐ๊ฒฝ ์ ์šฉ ===
201
  def apply_background_center_only():
 
202
  st.markdown("""
203
  <style>
204
+ /* 0) ์•ฑ ์ „์ฒด ๋ฐฐ๊ฒฝ ์ œ๊ฑฐ (์‚ฌ์ด๋“œ๋ฐ” ์ œ์™ธ) */
205
+ .stApp { background: none !important; }
206
  .stApp::before, .block-container::before { content: none !important; }
 
207
 
208
+ /* 1) ์ค‘์•™ ์ปจํ…Œ์ด๋„ˆ(๋ฒ„์ „๋ณ„ ๋ชจ๋“  ์ผ€์ด์Šค ํฌ๊ด„) */
209
+ /* - ์ตœ์‹ /๊ตฌ๋ฒ„์ „ DOM์„ ๋ชจ๋‘ ์ปค๋ฒ„ํ•˜๋„๋ก :is()์™€ data-testid๋ฅผ ๋ณ‘ํ–‰ */
210
+ :is(
211
+ [data-testid="stAppViewContainer"] [data-testid="block-container"],
212
+ [data-testid="stAppViewContainer"] > .main .block-container,
213
+ section.main > div.block-container,
214
+ div[data-testid="block-container"]
215
+ ){
216
  position: relative;
217
  isolation: isolate;
218
+ overflow: hidden;
219
+ min-height: 100vh; /* ์ „์ฒด ํ™”๋ฉด ์ฑ„์›€ */
220
+ /* ํ•„์š” ์‹œ: border-radius: 12px; */
221
+ /* ๋ชจ๋ฐ”์ผ/GPU ๊ฐ€์† ํžŒํŠธ */
222
+ transform: translateZ(0);
223
+ will-change: background-position, background-image;
224
  }
225
 
226
+ /* 2) ์ž…๋ ฅ๋ฐ•์Šค ํ•˜๋‹จ ์—ฌ๋ฐฑ */
227
+ div[data-testid="stTextInput"]{ margin-bottom: 18px !important; }
228
  </style>
229
  """, unsafe_allow_html=True)
230
 
231
+ # 3) ์ด๋ฏธ์ง€/๋‹จ์ƒ‰ ๋ถ„๊ธฐ
232
  if st.session_state.get("bg_on"):
 
233
  st.markdown(f"""
234
  <style>
235
+ :is(
236
+ [data-testid="stAppViewContainer"] [data-testid="block-container"],
237
+ [data-testid="stAppViewContainer"] > .main .block-container,
238
+ section.main > div.block-container,
239
+ div[data-testid="block-container"]
240
+ ){{
241
  background-image:
242
  linear-gradient(rgba(255,255,255,0.85), rgba(255,255,255,0.85)),
243
+ url('{BG_URL}') !important;
244
+ background-position: center 45% !important;
245
+ background-size: cover !important;
246
+ background-repeat: no-repeat !important;
247
+ /* ์˜ค๋ฒ„๋ ˆ์ด๋Š” ์Šคํฌ๋กค, ์ด๋ฏธ์ง€๋Š” ๊ณ ์ •(ํŒจ๋Ÿด๋ž™์Šค๊ฐ€ ์‹ซ์œผ๋ฉด fixedโ†’scroll) */
248
+ background-attachment: scroll, fixed !important;
 
249
  }}
250
 
251
+ /* ๋ชจ๋ฐ”์ผ์—์„œ fixed ๋ฌธ์ œ ํšŒํ”ผ */
252
+ @media (max-width: 768px){{
253
+ :is(
254
+ [data-testid="stAppViewContainer"] [data-testid="block-container"],
255
+ [data-testid="stAppViewContainer"] > .main .block-container,
256
+ section.main > div.block-container,
257
+ div[data-testid="block-container"]
258
+ ){{
259
+ background-attachment: scroll, scroll !important;
260
  }}
261
  }}
262
  </style>
263
  """, unsafe_allow_html=True)
264
  else:
 
265
  color = st.session_state.get("bg_color", "#F1F1F1")
266
  st.markdown(f"""
267
  <style>
268
+ :is(
269
+ [data-testid="stAppViewContainer"] [data-testid="block-container"],
270
+ [data-testid="stAppViewContainer"] > .main .block-container,
271
+ section.main > div.block-container,
272
+ div[data-testid="block-container"]
273
+ ){{
274
  background-image: none !important;
275
  background-color: {color} !important;
276
  }}