kargaranamir commited on
Commit
90a720b
1 Parent(s): 5d341d7

add responsive.

Browse files
Files changed (1) hide show
  1. utils.py +3 -2
utils.py CHANGED
@@ -23,7 +23,7 @@ def df_to_html(df):
23
  {'selector': 'td, th', 'props': [('border', 'none'), ("text-align", "center"), ('font-size', 'smaller')]}, # Remove cell borders, reduce font size
24
  {'selector': 'tr:hover', 'props': [('background-color', '#878787')]},
25
  {'selector': 'a:hover', 'props': [('color', 'darkblue')]},
26
- {'selector': 'table', 'props': [('border-collapse', 'collapse'), ('border', 'none'), ('border-bottom', '1px solid black'), ('width', '50%')]}, # Set table width to 50%
27
  {'selector': 'thead', 'props': [('border', 'none')]}, # Hide header border
28
  {'selector': 'tbody td', 'props': [('border-left', 'none'), ('border-right', 'none')]},
29
  {'selector': 'tr:not(:first-child) td', 'props': [('border-left', 'none'), ('border-right', 'none'), ('border-top', 'none')]},
@@ -31,13 +31,14 @@ def df_to_html(df):
31
  ]
32
 
33
  # Apply table styles and convert DataFrame to HTML
34
- styled_html = df.style.hide(axis="index").set_table_styles(styles).to_html(escape=False, index=False, bold_rows=True, justify='center').replace('<td>', '<td align="center">')
35
 
36
  return styled_html
37
 
38
 
39
 
40
 
 
41
  @st.cache_data
42
  def render_svg(svg):
43
  """Renders the given svg string."""
 
23
  {'selector': 'td, th', 'props': [('border', 'none'), ("text-align", "center"), ('font-size', 'smaller')]}, # Remove cell borders, reduce font size
24
  {'selector': 'tr:hover', 'props': [('background-color', '#878787')]},
25
  {'selector': 'a:hover', 'props': [('color', 'darkblue')]},
26
+ {'selector': '.responsive-table', 'props': [('width', '100%')]}, # Set table width to 100%
27
  {'selector': 'thead', 'props': [('border', 'none')]}, # Hide header border
28
  {'selector': 'tbody td', 'props': [('border-left', 'none'), ('border-right', 'none')]},
29
  {'selector': 'tr:not(:first-child) td', 'props': [('border-left', 'none'), ('border-right', 'none'), ('border-top', 'none')]},
 
31
  ]
32
 
33
  # Apply table styles and convert DataFrame to HTML
34
+ styled_html = '<div style="max-width: 100%; overflow-x: auto;">' + df.style.hide(axis="index").set_table_styles(styles).to_html(escape=False, index=False, bold_rows=True, justify='center').replace('<td>', '<td align="center" class="responsive-table">') + '</div>'
35
 
36
  return styled_html
37
 
38
 
39
 
40
 
41
+
42
  @st.cache_data
43
  def render_svg(svg):
44
  """Renders the given svg string."""