Update app.py
Browse files
app.py
CHANGED
|
@@ -51,26 +51,34 @@ st.markdown("""
|
|
| 51 |
}
|
| 52 |
.podium {
|
| 53 |
text-align: center;
|
| 54 |
-
|
| 55 |
margin: 0 10px;
|
| 56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
border: 2px solid #000;
|
| 58 |
color: #333;
|
| 59 |
font-weight: bold;
|
| 60 |
display: flex;
|
| 61 |
-
|
| 62 |
-
justify-content:
|
|
|
|
| 63 |
}
|
| 64 |
-
.podium.first {
|
| 65 |
-
height: 150px; /*
|
| 66 |
background-color: #ffd700; /* 金色 */
|
| 67 |
}
|
| 68 |
-
.podium.second {
|
| 69 |
-
height: 120px; /*
|
| 70 |
background-color: #c0c0c0; /* 銀色 */
|
| 71 |
}
|
| 72 |
-
.podium.third {
|
| 73 |
-
height: 90px; /*
|
| 74 |
background-color: #cd7f32; /* 銅色 */
|
| 75 |
}
|
| 76 |
.podium-label {
|
|
@@ -302,41 +310,51 @@ def main():
|
|
| 302 |
top_3 = valid_df.head(3)
|
| 303 |
|
| 304 |
if len(top_3) > 0:
|
| 305 |
-
#
|
| 306 |
-
podium_html = '<div class="podium-container">'
|
| 307 |
|
| 308 |
# 第二名(如果有)
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 317 |
|
| 318 |
# 第一名(如果有)
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 327 |
|
| 328 |
# 第三名(如果有)
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
|
|
|
|
|
|
|
| 340 |
else:
|
| 341 |
st.warning("無有效的查詢結果可供顯示頒獎台。")
|
| 342 |
else:
|
|
|
|
| 51 |
}
|
| 52 |
.podium {
|
| 53 |
text-align: center;
|
| 54 |
+
width: 120px;
|
| 55 |
margin: 0 10px;
|
| 56 |
+
display: flex;
|
| 57 |
+
flex-direction: column;
|
| 58 |
+
}
|
| 59 |
+
.podium-filler {
|
| 60 |
+
background-color: #1a1a1a; /* 與背景同色 */
|
| 61 |
+
flex-grow: 0;
|
| 62 |
+
}
|
| 63 |
+
.podium-step {
|
| 64 |
border: 2px solid #000;
|
| 65 |
color: #333;
|
| 66 |
font-weight: bold;
|
| 67 |
display: flex;
|
| 68 |
+
align-items: center;
|
| 69 |
+
justify-content: center;
|
| 70 |
+
flex-grow: 0;
|
| 71 |
}
|
| 72 |
+
.podium-step.first {
|
| 73 |
+
height: 150px; /* 第一名完整高度 */
|
| 74 |
background-color: #ffd700; /* 金色 */
|
| 75 |
}
|
| 76 |
+
.podium-step.second {
|
| 77 |
+
height: 120px; /* 第二名高度 */
|
| 78 |
background-color: #c0c0c0; /* 銀色 */
|
| 79 |
}
|
| 80 |
+
.podium-step.third {
|
| 81 |
+
height: 90px; /* 第三名高度 */
|
| 82 |
background-color: #cd7f32; /* 銅色 */
|
| 83 |
}
|
| 84 |
.podium-label {
|
|
|
|
| 310 |
top_3 = valid_df.head(3)
|
| 311 |
|
| 312 |
if len(top_3) > 0:
|
| 313 |
+
col1, col2, col3 = st.columns(3) # 創建三列
|
|
|
|
| 314 |
|
| 315 |
# 第二名(如果有)
|
| 316 |
+
with col1:
|
| 317 |
+
if len(top_3) >= 2:
|
| 318 |
+
second = top_3.iloc[1]
|
| 319 |
+
st.markdown(
|
| 320 |
+
f'<div class="podium">'
|
| 321 |
+
f'<div class="podium-filler" style="height: 30px;"></div>' # 填充 30px
|
| 322 |
+
f'<div class="podium-step second">{int(second["查詢結果"])}</div>'
|
| 323 |
+
f'<div class="podium-label">{second["姓名"]}\n{second["幸運號碼"]}</div>'
|
| 324 |
+
f'</div>',
|
| 325 |
+
unsafe_allow_html=True
|
| 326 |
+
)
|
| 327 |
+
else:
|
| 328 |
+
st.markdown('<div class="podium"><div class="podium-filler" style="height: 30px;"></div><div class="podium-step second"></div><div class="podium-label"></div></div>', unsafe_allow_html=True)
|
| 329 |
|
| 330 |
# 第一名(如果有)
|
| 331 |
+
with col2:
|
| 332 |
+
if len(top_3) >= 1:
|
| 333 |
+
first = top_3.iloc[0]
|
| 334 |
+
st.markdown(
|
| 335 |
+
f'<div class="podium">'
|
| 336 |
+
f'<div class="podium-step first">{int(first["查詢結果"])}</div>'
|
| 337 |
+
f'<div class="podium-label">{first["姓名"]}\n{first["幸運號碼"]}</div>'
|
| 338 |
+
f'</div>',
|
| 339 |
+
unsafe_allow_html=True
|
| 340 |
+
)
|
| 341 |
+
else:
|
| 342 |
+
st.markdown('<div class="podium"><div class="podium-step first"></div><div class="podium-label"></div></div>', unsafe_allow_html=True)
|
| 343 |
|
| 344 |
# 第三名(如果有)
|
| 345 |
+
with col3:
|
| 346 |
+
if len(top_3) >= 3:
|
| 347 |
+
third = top_3.iloc[2]
|
| 348 |
+
st.markdown(
|
| 349 |
+
f'<div class="podium">'
|
| 350 |
+
f'<div class="podium-filler" style="height: 60px;"></div>' # 填充 60px
|
| 351 |
+
f'<div class="podium-step third">{int(third["查詢結果"])}</div>'
|
| 352 |
+
f'<div class="podium-label">{third["姓名"]}\n{third["幸運號碼"]}</div>'
|
| 353 |
+
f'</div>',
|
| 354 |
+
unsafe_allow_html=True
|
| 355 |
+
)
|
| 356 |
+
else:
|
| 357 |
+
st.markdown('<div class="podium"><div class="podium-filler" style="height: 60px;"></div><div class="podium-step third"></div><div class="podium-label"></div></div>', unsafe_allow_html=True)
|
| 358 |
else:
|
| 359 |
st.warning("無有效的查詢結果可供顯示頒獎台。")
|
| 360 |
else:
|