programming/Python

[파이썬] streamlit에 html&css 적용하기

Jofresh 2023. 12. 26. 21:29
728x90
반응형

streamlit 라이브러리에 html&css코드 적용시키기

반응형

1. 쌍따옴표 3개 안에 원하는 html&css코드를 넣어준 뒤, [html_css]라고 정의해준다.

2. streamlit의 markdown 함수로 [html_css]를 실행한다.


html_css = """
    <style>
    table.customTable {
      width: 100%;
      background-color: #FFFFFF;
      border-collapse: collapse;
      border-width: 2px;
      border-color: #7EA8F8;
      border-style: solid;
      color: #000000;
}
</style>
<table class="customTable">
  <thead>
    <tr>
      <th>Header 1</th>
      <th>Header 2</th>
      <th>Header 3</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Row 1, Cell 1</td>
      <td>Row 1, Cell 2</td>
      <td>Row 1, Cell 3</td>
    </tr>
    <tr>
      <td>Row 2, Cell 1</td>
      <td>Row 2, Cell 2</td>
      <td>Row 2, Cell 3</td>
    </tr>
    <tr>
      <td>Row 3, Cell 1</td>
      <td>Row 3, Cell 2</td>
      <td>Row 3, Cell 3</td>
    </tr>
    <tr>
      <td>Row 4, Cell 1</td>
      <td>Row 4, Cell 2</td>
      <td>Row 4, Cell 3</td>
    </tr>
  </tbody>
</table>
"""

st.markdown(html_css)
728x90
반응형