首页 > 解决方案 > 使用 plotly/dash 更改链接的外观

问题描述

我正在与Dash合作构建仪表板。考虑以下代码:

def get_index():
    index = html.Div([
        dcc.Link('Page 1', href='/page-1'),
        html.Br(),
        dcc.Link('Page 2', href='/page-2')
    ], style = {'display':'inline-block','columnCount': 2})
    return index

这在我的应用程序中为我提供了以下输出:

在此处输入图像描述

问题:如何删除链接下方的栏并更改字体和颜色?

谢谢!

标签: python-3.xplotlyplotly-dash

解决方案


您可以通过添加style为命名参数来自定义链接,例如

dcc.Link('Page 1', href='/page-1', 
         style={'font-family': 'Times New Roman, Times, serif', 'font-weight': 'bold'})

style 参数只是普通的 CSS。

在我看来,向你的 Dash 应用程序添加外部 CSS更可取,因为你可以分离代码逻辑和布局。


推荐阅读