code-slicer commited on
Commit
66ed75f
·
verified ·
1 Parent(s): f487cd2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -15
app.py CHANGED
@@ -194,7 +194,7 @@ BG_URL = "https://plus.unsplash.com/premium_photo-1679830513869-cd3648acb1db?q=8
194
  st.sidebar.subheader("🎨 배경 설정")
195
  use_img = st.sidebar.toggle("배경 이미지 사용", key="bg_on", value=True)
196
 
197
- # ✅ 배경 CSS (둘 중 하나만 적용)
198
  bg_layer_css = (
199
  f"""
200
  /* 이미지 모드: 15%만 보이도록 흰색 85% 오버레이 */
@@ -204,33 +204,48 @@ bg_layer_css = (
204
  background-position: center 45%, center 45%;
205
  background-size: cover, cover;
206
  background-repeat: no-repeat, no-repeat;
207
- background-attachment: fixed, fixed; /* 스크롤 고정 */
208
  """
209
  if use_img else
210
  """
211
  /* 단색 모드 */
212
- background-color: #F1F1F1;
213
  """
214
  )
215
 
216
  st.markdown(f"""
217
  <style>
218
- /* 전역 배경 리셋 */
219
- .stApp::before, .stApp::after {{ content: none !important; }}
220
- .stApp {{ background: transparent !important; }}
221
-
222
- /* 중앙 컬럼에만 배경 적용 */
223
- .block-container {{
224
- position: relative;
225
- min-height: 100vh;
 
 
 
 
226
  {bg_layer_css}
 
 
 
 
 
 
 
 
 
227
  }}
228
 
229
- /* 불필요한 pseudo 레이어 제거 (충돌 방지) */
230
- .block-container::before, .block-container::after {{ content: none; }}
231
 
232
- /* 콘텐츠는 그대로 */
233
- .block-container > * {{ position: relative; }}
 
 
 
234
  </style>
235
  """, unsafe_allow_html=True)
236
 
 
194
  st.sidebar.subheader("🎨 배경 설정")
195
  use_img = st.sidebar.toggle("배경 이미지 사용", key="bg_on", value=True)
196
 
197
+ # ✅ 배경(둘 중 하나만 적용)
198
  bg_layer_css = (
199
  f"""
200
  /* 이미지 모드: 15%만 보이도록 흰색 85% 오버레이 */
 
204
  background-position: center 45%, center 45%;
205
  background-size: cover, cover;
206
  background-repeat: no-repeat, no-repeat;
 
207
  """
208
  if use_img else
209
  """
210
  /* 단색 모드 */
211
+ background: #F1F1F1;
212
  """
213
  )
214
 
215
  st.markdown(f"""
216
  <style>
217
+ /* ⚠ 기존에 .stApp::before 를 끄던 코드가 있으면 삭제(또는 아래가 마지막에 오게) */
218
+
219
+ /* 중앙 폭 변수: 페이지 전체(뷰포트) 기준 중앙에 이 폭만 보이도록 클립 */
220
+ :root {{
221
+ --col-w: min(1100px, 95vw);
222
+ }}
223
+
224
+ /* ✅ 배경은 '뷰포트 고정' 단일 레이어 (끊김 없음) */
225
+ .stApp::before {{
226
+ content: "" !important;
227
+ position: fixed;
228
+ inset: 0; /* 풀스크린 */
229
  {bg_layer_css}
230
+ pointer-events: none;
231
+ z-index: 0;
232
+
233
+ /* 중앙 컬럼 폭만 보이도록 좌우를 잘라냄 */
234
+ clip-path: inset(0 calc((100vw - var(--col-w)) / 2) 0 calc((100vw - var(--col-w)) / 2));
235
+
236
+ /* 페인팅 안정화(티어링 방지 보정) */
237
+ will-change: transform;
238
+ transform: translateZ(0);
239
  }}
240
 
241
+ /* 본문은 배경 위에 */
242
+ .block-container > * {{ position: relative; z-index: 1; }}
243
 
244
+ /* 모바일에서 성능 이슈가 있으면 여기서 이미지 모드만 스크롤형으로 전환 가능
245
+ @media (max-width: 768px){{
246
+ .stApp::before {{ background-attachment: scroll; }}
247
+ }}
248
+ */
249
  </style>
250
  """, unsafe_allow_html=True)
251