Skip to content
This repository was archived by the owner on Jun 22, 2019. It is now read-only.

Table width breaks layout when loading an local css file #45

Open
ptim opened this issue Feb 4, 2018 · 4 comments
Open

Table width breaks layout when loading an local css file #45

ptim opened this issue Feb 4, 2018 · 4 comments

Comments

@ptim
Copy link

ptim commented Feb 4, 2018

Love your work!

I'm using a workaround to load a local stylesheet from here:
https://community.plot.ly/t/how-do-i-use-dash-to-add-local-css/4914/9

I find that:

  • datatable loads inside .container, sets its own width to page width
  • stylesheet loads, sets the .container width to 960px
  • datatable overflows .container (see screenshot)
  • resizing the window updates the datatable width, correcting the issue

Funnily enough - it doesn't seem to occur when using your codepen URL:
https://codepen.io/chriddyp/pen/bWLwgP.css

Wasn't sure of the best place to report this - figured that it was likely a datatable issue, but maybe it relates to / is solved by allow optional header and footer #171

For the moment, I'm just adding overflow-x: scroll to the container, but I'd thought you'd like to know...

Cheers, ptim

2018-02-04 17-45-46 - dash 1

@janimo
Copy link

janimo commented Feb 22, 2018

Confirmed with 0.6.0. Inline styles work whereas a css loaded via html.Link doesn't; both are setting the same css grid properties.

@Nyahua
Copy link

Nyahua commented Apr 14, 2018

Same question for me.
my code:

import dash
from dash.dependencies import Input, Output
import dash_core_components as dcc
import dash_html_components as html
import dash_table_experiments as dt
import pandas as pd

app = dash.Dash(__name__, static_folder='assets')

app.scripts.config.serve_locally = True
app.css.config.serve_locally = True

df = pd.DataFrame({
    'x': ['A', 'B', 'C', 'D', 'E', 'F'],
    'y': [4, 3, 1, 2, 3, 6],
    'z': ['a', 'b', 'c', 'a', 'b', 'c']
})

app.layout = html.Div([
    html.H4('DataTable'),
    dt.DataTable(
        # Initialise the rows
        rows=df.to_dict('records'),
        columns = list(df.columns),
        row_selectable=True,
        filterable=False,
        sortable=True,
        selected_row_indices=[],
        id='dt-gps'
    ),
    html.Link(href='/assets/bWLwgP.css', rel='stylesheet'),
], className='container')

if __name__ == '__main__':
    app.run_server()

@Nyahua
Copy link

Nyahua commented Apr 14, 2018

@ptim where do you add the overflow-x: scroll?
I added it to my local css file, but it seems not work:

.container {
  position: relative;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 20px;
  overflow-x: scroll;
  box-sizing: border-box; }

@ghost
Copy link

ghost commented Aug 27, 2018

html.Div(id='system_info_container1', style={'max-width': '600px', 'overflow-x': 'scroll'},
        children=[
        generate_table(global_example_csv_dataframe_system_info, max_rows=1)
], className='four columns'),

Here's how I made it work. Just override the css-styling in your python code using the style variable.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants